- All (478)
- jom (0)
- Qt Linguist (7)
- Qt Eclipse Integration (9)
- Qt Designer (7)
- Qt Creator (4)
- Qt build system: qmake (31)
- Qt build system: configure (3)
- Qt Assistant (5)
- Printing (4)
- Porting from Qt 3 to Qt 4 (1)
- Plugins (7)
- Qt Visual Studio AddIn (2)
- Qt/MFC Migration (2)
- QtScript (3)
- MDI (2)
- XML (1)
- Widgets (22)
- WebKit (5)
- Tools and Containers (2)
- Threads (2)
- Text Handling (10)
- SQL (6)
- QtTest (1)
- QtService (1)
- Platform: Windows (49)
- Platform: Unix (16)
- Platform: Mac OS X (18)
- Image Formats (2)
- I/O (2)
- Graphicsview (8)
- Font handling (9)
- Event System (18)
- Drag and Drop (4)
- Dialogs (6)
- Desktop integration (3)
- ActiveQt (3)
- Itemviews (60)
- Layout (4)
- Qt Quick (10)
- Qt SDK (1)
- Licensing (2)
- Platform: Embedded Linux (38)
- Painting (32)
- OpenGL (4)
- Object Model (6)
- Network (5)
- Multimedia (3)
- Miscellanous (23)
- Main Window (19)
- Look and Feel (23)
- Development (0)
- Getting Involved (0)
- Routines (0)
I have problems building an application that uses a Qt Designer plugin on Windows. Can you give some advice?
First of all, you need to export your class so that it can be used by the
plugin, e.g:
Also, make sure you have the Q_OBJECT macro in your class declaration, if you
do not include it then the plugin will not have access to the correct
QMetaObject which would have information about the class itself. As a result
this would break the introspection of the plugin.
In the .pro file of your plugin you also need to give some extra information
- TEMPLATE = lib
Make sure you specify the lib template since you are building a library.
- DESTDIR = $$[QT_INSTALL_PLUGINS]/designer
In addition you need to specify where the plugin should be located. Qt will
look in plugins/designer by default, so this is where your plugin should be.
An example .pro file may like look this:
- TEMPLATE = lib
- CONFIG+= designer plugin debug_and_release
- LANGUAGE = C++
- TARGET = buttonPlugin
- SOURCES += buttonPlugin.cpp button.cpp
- HEADERS += buttonPlugin.h button.h
- DESTDIR = $$[QT_INSTALL_PLUGINS]/designer
- CONFIG += qt warn_on release plugin
With your application you need to add the following to your application’s .pro
file:
- LIBS+=$$[QT_INSTALL_PLUGINS]/designer/nameOfYourPlugin.lib
This line is necessary to link against the lib file and at runtime the
application will use the dll. The lib file is located at
$$[QT_INSTALL_PLUGINS]/designer since this is what was specified as the
DESTDIR in the plugin’s pro file.
- INCLUDEPATH += text/example/yourPluginDir/yourWidget
You also need to specify the INCLUDEPATH, so that your application will be
able to find your custom widget’s header file.
An example .pro file can look as follows:
- TEMPLATE = app
- LANGUAGE = C++
- LIBS += $$[QT_INSTALL_PLUGINS]/designer/buttonPlugin.lib
- INCLUDEPATH += text/example/yourPluginDir/yourWidget
- CONFIG += qt warn_on release
- SOURCES += main.cpp
- FORMS = form1.ui
Finally, your application also needs to be able to find the plugin’s dll. This
can be done either by putting the myPlugin.dll into the same directory as your
application, or by adding the path to the myPlugin.dll to the PATH environment
variable.

No comments