Exposing your plugin to Qt Designer
The FilterWidget
class is completed and ready to be used. We now have to register FilterWidget
with the Qt Designer plugin system. This glue code is made using a child class of QDesignerCustomWidgetInterface
.
Create a new C++ class named FilterPluginDesigner
and update FilterPluginDesigner.h
like so:
#include <QtUiPlugin/QDesignerCustomWidgetInterface> class FilterPluginDesigner : public QObject, public QDesignerCustomWidgetInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.masteringqt.imagefilter.FilterWidgetPluginInterface") Q_INTERFACES(QDesignerCustomWidgetInterface) public: FilterPluginDesigner(QObject* parent = 0); };
The FilterPlugin
class inherits from two classes:
The
QObject
class, to rely on the Qt parenting systemThe
QDesignerCustomWidgetInterface
class to properly expose theFilterWidget
information to the plugin system
The QDesignerCustomWidgetInterface
class brings two new macros:
The
Q_PLUGIN_METADATA()
macro...