Correct way to write plugins
-
Hi all,
I am not sure what is the correct/better way to write plugins for my application. I am confused as when I look at an example called "echoplugin" I can see following code for plugin main class definition:
@
#define ECHOPLUGIN_H#include <QObject>
#include <QtPlugin>
#include "echointerface.h"//! [0]
class EchoPlugin : public QObject, EchoInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.EchoInterface" FILE "echoplugin.json")
Q_INTERFACES(EchoInterface)public:
QString echo(const QString &message);
};
//! [0]#endif
@When I try to make new liblary using Qt Creator, the enviroment generates totaly diferent template:
@
#ifndef UNTITLED_H
#define UNTITLED_H#include "untitled_global.h"
class UNTITLEDSHARED_EXPORT Untitled
{public:
Untitled();
};#endif // UNTITLED_H
@So my question is which way to write plugin is better and how should I use Qt Creator to do it.
-
Hi,
You can either start from the library template and add the modifications needed to make it a plugin or copy e.g. the plug and paint plugin example and modify it to suite your needs.