Qt如何加载动态插件?
我把设备上的几个按钮按键的相关操作(open,read,及按键映射到Qt等)制作成了一个动态插件(生成文件libkeypad.so),把它放在文件系统的qt-4.5/plugins/目录下,在应用程序中通过QPluginLoader装载插件,但是好像没有装载上,按什么键都没反映下面是装载插件的函数 --此函数在主对象的构造函数中调用
void layout1::loadPlugins()
{
std::cout<<"start to load the plugin!"<<std::endl; //1
QPluginLoader loader("/qt-4.5/plugins/libkeypad.so");
QObject *instance = loader.instance();
if(instance){
std::cout<<"load the plugin OK!"<<std::endl; //2
KeyInterface *interface =
qobject_cast<KeyInterface *>(instance);
interfaces.append(interface);
}
std::cout<<"finish to load the plugin!"<<std::endl; //3
}
开机后1,3处的信息都显示出来了,2处信息没有,应该是插件没装载成功吧?
库是否是交叉编绎过的? 和应用程序用相同的方法编译的
我参考他的插件程序
http://www.armbbs.net/forum.php?mod=viewthread&tid=11591
页:
[1]