Exposing your plugin to Qt Designer
The FilterWidget
class is completed and ready to be used. We now have to register the FilterWidget
class 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
as shown in the following code:
#include <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 system - The
QDesignerCustomWidgetInterface
class, to properly expose theFilterWidget
information to the plugin system
The QDesignerCustomWidgetInterface
class brings two new macros...