Trying to create a plugin in C ++ / Qt

I am creating a task-based program that should have plugins. Tasks should have properties that can be easily edited, I think that this can be done using the reflection capabilities of the Qt Meta-Object compiler (can I be wrong, but should I be able to do this in QtPropertyBrowser?)

So here is the base:

class Task : public QObject
{
Q_OBJECT
public:
    explicit Task(QObject *parent = 0) : QObject(parent){}

    virtual void run() = 0;

signals:
    void taskFinished(bool success = true);
}

Then the plugin could accomplish this task:

class PrinterTask : public Task
{
Q_OBJECT
public:
    explicit PrinterTask(QObject *parent = 0) : Task(parent) {}

    void run()
    {
        Printer::getInstance()->Print(this->getData());  // fictional
        emit taskFinished(true); 
    }

    inline const QString &getData() const;
    inline void setData(QString data);

Q_PROPERTY(QString data READ getData WRITE setData) // for reflection
}

In short, here is what I want to do:

// load plugin
// find all the Tasks interface implementations in it
// have user able to choose a Task and edit its specific Q_PROPERTY's
// run the TASK

It is important that a single .dll has several tasks, because I want them to be linked by their module. For example, "FileTasks.dll" may have tasks for deleting files, creating files, etc.

Qt - X .dll. , ( ?). , , , - FactoryInterface , ( Qt Plug-And-Paint), , .

- ++, Qt, , ?

, , Qt- , (.. QtPropertyBrowser )?

+5
2

, , . Qt, , :

+6

, Qt ?

.

: ,

,

. plug-and-paint , . factory, , QObjects, . .

+4

All Articles