Comment émettre un signal depuis un plugin et s'y connecter dans le programme principal ?
Bonjour,
J'ai créé un plugin avec qt, et j'aimerai faire communiquer ce plugin avec le programme principal en utilisant des signaux.
Le problème est que quand je me connecte au signal dans le programme, j'ai une erreur à la compilation !!!
Voici le code de mon l'interface:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#ifndef PLUGININTERFACE_H
#define PLUGININTERFACE_H
#include <QObject>
#include <QString>
class PluginInterface
{
public:
virtual ~PluginInterface() = default;
virtual QString getDataXml() = 0;
virtual QString pluginName() = 0;
virtual QList<QString> execAction(QList<QString> cmd) = 0;
};
QT_BEGIN_NAMESPACE
#define PluginInterface_iid "fr.swiftapp.linux.plugin.HelloWord"
Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid)
QT_END_NAMESPACE
#endif |
Du Plugin.h:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#ifndef HELLOWORDPLUGIN_H
#define HELLOWORDPLUGIN_H
#include <QObject>
#include <QtPlugin>
#include "plugininterface.h"
class HelloWordPlugin : public QObject, PluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "fr.swiftapp.linux.plugin.HelloWord" FILE "hellowordplugin.json")
Q_INTERFACES(PluginInterface)
public:
QString getDataXml() override;
QString pluginName() override;
QList<QString> execAction(QList<QString> cmd) override;
};
#endif |
Du Plugin.cpp:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include "hellowordplugin.h"
#include <QFile>
QString HelloWordPlugin::getDataXml()
{
QFile file(":/XML/Data.xml");
file.open(QIODevice::ReadOnly);
return file.readAll();
}
QString HelloWordPlugin::pluginName()
{
return "Hello Word";
}
QList<QString> HelloWordPlugin::execAction(QList<QString> cmd) {
} |
Du coup, si quelqu'un sait comment faire, je suis preneur !!! ;)
Merci d'avance !