#include <QtPlugin>#include <QWidget>class PluginInterface : public QWidget {public: virtual ~PluginInterface() { } virtual void start() = 0; virtual void settings() = 0; //signal virtual void notificationIsReady(const QString& title, const QString& description, const QString& image) = 0;};Q_DECLARE_INTERFACE(PluginInterface, "com.devlab.Notifier.PluginInterface")
#include <PluginInterface.hpp>#include <QTimer>class TestPlugin : public PluginInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "com.devlab.Notifier.PluginInterface") Q_INTERFACES(PluginInterface)private: QTimer* timer;public: TestPlugin(); virtual ~TestPlugin(); virtual void start(); virtual void settings();signals: void notificationIsReady(const QString& title, const QString& description, const QString& image);private slots: void timerSlot();};TestPlugin::TestPlugin() { timer = new QTimer(this); timer->setInterval(1000);}TestPlugin::~TestPlugin() { delete timer;}void TestPlugin::start() { connect(timer, &QTimer::timeout, this, &TestPlugin::timerSlot); timer->start();}void TestPlugin::settings() { }void TestPlugin::timerSlot() { emit notificationIsReady("Test", "It's works", "");}
QString path("C:/Users/devnikor/Documents/Projects/Notifier/Notifier/plugins/TestPlugin.dll"); QPluginLoader loader(path); QObject* plugin = loader.instance(); PluginInterface* testPlugin = qobject_cast<PluginInterface*>(plugin); connect(testPlugin, SIGNAL(notificationIsReady(QString, QString, QString)), this, SLOT(testSlot(QString, QString, QString)));
"Plugin verification data mismatch in 'C:/Users/devnikor/Documents/Projects/Notifier/Notifier/plugins/TestPlugin.dll'"
QT += core widgetsTEMPLATE = lib CONFIG += pluginINCLUDEPATH += ../Notifier/NotifierHEADERS += \ testplugin.hppSOURCES += \ testplugin.cppDESTDIR = ../Notifier/Notifier/plugins
C:\Users\devnikor\Documents\Projects\Notifier\Notifier\notificationcenter.cpp:35: ошибка: no matching function for call to 'NotificationCenter::connect(PluginInterface*&, const char*, NotificationCenter* const, const char*)' this, SLOT(testSlot(const QString&,const QString&,const QString&))); ^
connect(testPlugin, SIGNAL(notificationIsReady(const QString&,const QString&,const QString&)), this, SLOT(testSlot(const QString&,const QString&,const QString&)));