Hi,
I've followed this tutorial http://web.mit.edu/qt-dynamic/www/de...getplugin.html to create my own customized widget. After doing the "make" and "make install" I've seen a library file created in my workspace and as well as in the /designer directory. However when I reload the designer, I don't see my custom widget in the widget box. Please help, these are the things that I've accomplished so far.
The .pro file.
CONFIG += designer \
plugin \
debug_and_release
TEMPLATE = lib
HEADERS += QCustomDialog.h \
QCustomDialogPlugin.h
SOURCES += QCustomDialog.cpp \
QCustomDialogPlugin.cpp
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
CONFIG += designer \
plugin \
debug_and_release
TEMPLATE = lib
HEADERS += QCustomDialog.h \
QCustomDialogPlugin.h
SOURCES += QCustomDialog.cpp \
QCustomDialogPlugin.cpp
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
To copy to clipboard, switch view to plain text mode
Here's my custom widget plugin.
#ifndef QCUSTOMDIALOGPLUGIN_H
#define QCUSTOMDIALOGPLUGIN_H
#include <QDesignerCustomWidgetInterface>
{
Q_OBJECT
public:
QCustomDialogPlugin
(QObject *parent
= 0);
bool isContainer() const;
bool isInitialized() const;
private:
bool initialized;
};
#endif // QCUSTOMDIALOGPLUGIN_H
#ifndef QCUSTOMDIALOGPLUGIN_H
#define QCUSTOMDIALOGPLUGIN_H
#include <QDesignerCustomWidgetInterface>
class QCustomDialogPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
QCustomDialogPlugin(QObject *parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool initialized;
};
#endif // QCUSTOMDIALOGPLUGIN_H
To copy to clipboard, switch view to plain text mode
#include "QCustomDialogPlugin.h"
#include "QCustomDialog.h"
#include <QString>
#include <QObject>
#include <QtPlugin>
QCustomDialogPlugin
::QCustomDialogPlugin(QObject *parent
){
initialized = false;
}
bool QCustomDialogPlugin::isInitialized() const
{
return initialized;
}
{
return new QCustomDialog(parent);
}
QString QCustomDialogPlugin
::name() const {
return "QCustomDialog";
}
QString QCustomDialogPlugin
::group() const {
return "Display Widgets [Examples]";
}
QIcon QCustomDialogPlugin
::icon() const {
}
QString QCustomDialogPlugin
::toolTip() const {
return "";
}
QString QCustomDialogPlugin
::whatsThis() const {
return "";
}
bool QCustomDialogPlugin::isContainer() const
{
return true;
}
QString QCustomDialogPlugin
::domXml() const {
return "<widget class=\"QCustomDialog\" name=\"customDialog\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>400</width>\n"
" <height>200</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>The current time</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>Qt Custom Dialog "
"the current time.</string>\n"
" </property>\n"
"</widget>\n";
}
QString QCustomDialogPlugin
::includeFile() const {
return "QCustomDialog.h";
}
Q_EXPORT_PLUGIN2(libCustomWidget, QCustomDialogPlugin)
#include "QCustomDialogPlugin.h"
#include "QCustomDialog.h"
#include <QString>
#include <QObject>
#include <QtPlugin>
QCustomDialogPlugin::QCustomDialogPlugin(QObject *parent)
: QObject(parent)
{
initialized = false;
}
bool QCustomDialogPlugin::isInitialized() const
{
return initialized;
}
QWidget *QCustomDialogPlugin::createWidget(QWidget *parent)
{
return new QCustomDialog(parent);
}
QString QCustomDialogPlugin::name() const
{
return "QCustomDialog";
}
QString QCustomDialogPlugin::group() const
{
return "Display Widgets [Examples]";
}
QIcon QCustomDialogPlugin::icon() const
{
return QIcon();
}
QString QCustomDialogPlugin::toolTip() const
{
return "";
}
QString QCustomDialogPlugin::whatsThis() const
{
return "";
}
bool QCustomDialogPlugin::isContainer() const
{
return true;
}
QString QCustomDialogPlugin::domXml() const
{
return "<widget class=\"QCustomDialog\" name=\"customDialog\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>400</width>\n"
" <height>200</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>The current time</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>Qt Custom Dialog "
"the current time.</string>\n"
" </property>\n"
"</widget>\n";
}
QString QCustomDialogPlugin::includeFile() const
{
return "QCustomDialog.h";
}
Q_EXPORT_PLUGIN2(libCustomWidget, QCustomDialogPlugin)
To copy to clipboard, switch view to plain text mode
I have not posted the widget class itself because I believe its already working. I've tried using it manually or without using the designer and it shows when run. 

Bookmarks