天嵌 ARM开发社区

 找回密码
 注册
查看: 2726|回复: 2

Qt如何加载动态插件?

[复制链接]
nice026 发表于 2013-1-24 14:28:39 | 显示全部楼层 |阅读模式
我把设备上的几个按钮按键的相关操作(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处信息没有,应该是插件没装载成功吧?
TQ-lkp 发表于 2013-1-24 16:31:46 | 显示全部楼层
库是否是交叉编绎过的?
 楼主| nice026 发表于 2013-1-24 16:38:33 | 显示全部楼层
和应用程序用相同的方法编译的
我参考他的插件程序
http://www.armbbs.net/forum.php?mod=viewthread&tid=11591
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-8 08:59 , Processed in 1.046875 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表