就不费话了,直接点
来一个我做的插件例子
//! 插件基类 class PluginAddon : public QObject
{
Q_OBJECT
public:
(){}
virtual ~(){}
public:
...
signals:
void notify(const Target& t);
};
Q_DECLARE_INTERFACE(,"ooo/1.0.0")
具体插件
class cPluginon
: public PluginAddon
{
Q_OBJECT
// 将该接口注册到Qt的meta-object system
Q_INTERFACES(PluginAddon)
public:
...
};
.cpp
Q_EXPORT_PLUGIN2(cplug_Plugin,cPluginon)
这个宏所在头文件是:
#include <QtPlugin>
至于插件的使用.
loader
= new QPluginLoader("dongrays_Plugin.dll"); QObject* instance = loader->instance();
if(instance)
{
interface = qobject_cast<Addon*>(instance);
connect(interface,SIGNAL(notify(target)),this,SLOT(getInfo(target)));
}
谈过connect照样可以再插件之前传送数据