How to add custom widget plugin in Designer's widget box? - Help
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.
Code:
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
Here's my custom widget plugin.
Code:
#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
Code:
#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)
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. :confused::confused::confused:
Re: How to add custom widget plugin in Designer's widget box? - Help
Open About Plugins in Designer/creator and see whether your library is already listed there. Then there should be an error message indicating that is going wrong.