TEMPLATE = libCONFIG += designer plugin releaseHEADERS = ../ColorButton/ColorButton.h \ ColorButtonPlugin.hSOURCES = ../ColorButton/ColorButton.cpp \ ColorButtonPlugin.cppRESOURCES = ColorButtonPlugin.qrcDESTDIR = $$[QT_INSTALL_PLUGINS]/designer
class ColorButtonPlugin : public QObject, public QDesignerCustomWidgetInterface{ Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface)public: ColorButtonPlugin(QObject *parent = 0); QString name() const; QString includeFile() const; QString group() const; QIcon icon() const; QString toolTip() const; QString whatsThis() const; bool isContainer() const; QWidget *createWidget(QWidget *parent);};
#include <QtPlugin>#include "../ColorButton/ColorButton.h"#include "ColorButtonPlugin.h"ColorButtonPlugin::ColorButtonPlugin(QObject *parent) : QObject(parent){}QString ColorButtonPlugin::name() const{ return "ColorButton";}QString ColorButtonPlugin::includeFile() const{ return "ColorButton.h";}QString ColorButtonPlugin::group() const{ return tr("My widgets");}QIcon ColorButtonPlugin::icon() const{ return QIcon(":/images/iconeditor.png");}QString ColorButtonPlugin::toolTip() const{ return tr("An color button widget");}QString ColorButtonPlugin::whatsThis() const{ return tr("Programmer: Okunev Grigory");}bool ColorButtonPlugin::isContainer() const{ return false;}QWidget *ColorButtonPlugin::createWidget(QWidget *parent){ return new ColorButton(parent);}Q_EXPORT_PLUGIN2(ColorButton, ColorButtonPlugin)
CONFIG -= debug