I was just reading up about QWidgets and I would like to create plugins that are widgets which will be loaded during runtime. When I was looking at the sample code and the requirements, the plugin seems to inherit from the interface and QObject. How would I create QWidget-plugins where they all have different buttons and different slots? Also, would it be possible to create a plugin that inherits from the interface and a baseclass that inherits from QWidget(that inherits from QObject).
http://developer.qt.nokia.com/doc/qt-4.8/plugins-howto.html
However, I read about metaobject where you can load widgets during runtime, just by knowing their names (doesn't require RTTI support). But exactly how would I delived the classes to the porject for it to recognize them? Whn dealing with plugins I need to have them in a special project that I compile with a different sets of flags in the .pro file. But how would I do it here?
I would really like to use the qtplugin but how?
An Idea:
Would it be acceptable and optimal to let the plugin create a QWidget that it returns? Don't really see the point of writing plugins to the designer if I create my interface without it. Or have I misunderstood it?
http://techbase.kde.org/Development/Tutorials/Writing_Qt_Designer_Plugins
class workspaceInterface {
virtual QWidget* createWorkspace(QWidget* parent);
... other useful functions...
}
class mySpecialWidget : public QWidget {
mySpecialWidget {
add a layout, add some buttons, maybe change the color
}
}
//plugin
#include "myspecialwidget.h"
class myPlugin : public QObject, public workspaceInterface {
QWidget* createWorkspace(QWidget* parent) {
return new MySpecialWidget();
}
....
}
All of this code I would put in one project, compile it as a plugin and then look for it in my main application and load it in. The I would create a instance of it and let it create a widget that I will display.
Is there any better way of doing this, or is this it?