PDA

View Full Version : Qt Designer plugin on windows



big4mil
29th May 2007, 22:45
Hi All,

I have successful created a Qt Designer plugin (customer groupbox) on linux. This plugin I also can successful use in my main window where I do display some customer information(compile and run without any errors).

Now I'm switching over to windows and I'm getting my first trouble with it. Creating the dll and the lib files could be done without any problems. But if I use the created plugin in a main window, I get the follwing errors/warnigs:


1>moc_userdetailsgb.cpp
1>.\debug\moc_userdetailsgb.cpp(41) : warning C4273: 'staticMetaObject': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'public: static QMetaObject const UserDetailsGB::staticMetaObject'
1>.\debug\moc_userdetailsgb.cpp(41) : error C2491: 'UserDetailsGB::staticMetaObject': Definition von Statisches Datenmember für dllimport nicht zulässig
1>.\debug\moc_userdetailsgb.cpp(47) : warning C4273: 'UserDetailsGB::metaObject': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'metaObject'
1>.\debug\moc_userdetailsgb.cpp(52) : warning C4273: 'UserDetailsGB::qt_metacast': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'qt_metacast'
1>.\debug\moc_userdetailsgb.cpp(60) : warning C4273: 'UserDetailsGB::qt_metacall': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'qt_metacall'
1>Das Buildprotokoll wurde unter "file://d:\Development\Projects\Test_MainWindow\debug\Buil dLog.htm" gespeichert.
1>testApp - 1 Fehler, 4 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========

Here the plugin pro file.

TEMPLATE = vclib
LANGUAGE = C++
TARGET = userdetailsgb
DESTDIR = C:\Qt\4.2.3\plugins\designer

target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
CONFIG += designer plugin debug_and_release

DEFINES += USERDETAILSGB_LIB

######################################
# Header files
######################################
HEADERS = ./src/userdetailsgb.h \
./src/userdetailsgbplugin.h \
./src/userdetailsgbpluginglobal.h \


######################################
# Source files
######################################
SOURCES = ./src/userdetailsgb.cpp \
./src/userdetailsgbplugin.cpp

here the userdetailsgbpluginglobal.h file:

#ifndef USERDETAILSGBPLUGINGLOBAL_H
#define USERDETAILSGBPLUGINGLOBAL_H

#include <Qt/qglobal.h>

#ifdef USERDETAILSGB_LIB
# define USERDETAILSGBPLUGIN_EXPORT Q_DECL_EXPORT
#else
# define USERDETAILSGBPLUGIN_EXPORT Q_DECL_IMPORT
#endif

#endif // USERDETAILSGBPLUGINGLOBAL_H

here the userdetailsgbplugin.h file

#ifndef USERDETAILSGBPLUGIN_H
#define USERDETAILSGBPLUGIN_H

#include "userdetailsgbpluginglobal.h"

#include <QObject>
#include <QDesignerCustomWidgetInterface>

class USERDETAILSGBPLUGIN_EXPORT UserDetailsGBPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES( QDesignerCustomWidgetInterface )

public:
UserDetailsGBPlugin( 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 // USERDETAILSGBPLUGIN_H

here the userdetailsgb.h file

#ifndef USERDETAILSGB_H
#define USERDETAILSGB_H

#include <QObject>
#include <QGroupBox>
#include <QtDesigner/QDesignerExportWidget>

class QDESIGNER_WIDGET_EXPORT UserDetailsGB : public QGroupBox
{
Q_OBJECT

public:
UserDetailsGB( QWidget * parent = 0 );
~UserDetailsGB() {}

};

#endif // USERDETAILSGB_H

and finally here the main app pro file

TEMPLATE = vcapp
TARGET = testApp
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += testmainwindow.h userdetailsgb.h
FORMS += mainwindow.ui
SOURCES += main.cpp testmainwindow.cpp

I'm using MSVC 2005 Express, Windows XP, Qt 4.2.3.
Any help on this would be great. Many thanks.
big4mil

high_flyer
29th May 2007, 23:39
Are you sure this is the first error?
Did you add Q_EXPORT_PLUGIN2(customwidgetplugin, MyCustomWidget) at the bottom of userdetailsgbpluginglobal.cpp?

big4mil
30th May 2007, 06:34
Hi,

thanks for your reply!

Yes, it is the first error. Below you can see the whole compiler output:

1>------ Neues Erstellen gestartet: Projekt: testApp, Konfiguration: Debug Win32 ------
1>Die Zwischen- und Ausgabedateien für das Projekt "testApp" mit der Konfiguration "Debug|Win32" werden gelöscht.
1>MOC userdetailsgb.h
1>UIC mainwindow.ui
1>MOC testmainwindow.h
1>Kompilieren...
1>main.cpp
1>testmainwindow.cpp
1>moc_testmainwindow.cpp
1>moc_userdetailsgb.cpp
1>.\debug\moc_userdetailsgb.cpp(41) : warning C4273: 'staticMetaObject': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'public: static QMetaObject const UserDetailsGB::staticMetaObject'
1>.\debug\moc_userdetailsgb.cpp(41) : error C2491: 'UserDetailsGB::staticMetaObject': Definition von Statisches Datenmember für dllimport nicht zulässig
1>.\debug\moc_userdetailsgb.cpp(47) : warning C4273: 'UserDetailsGB::metaObject': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'metaObject'
1>.\debug\moc_userdetailsgb.cpp(52) : warning C4273: 'UserDetailsGB::qt_metacast': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'qt_metacast'
1>.\debug\moc_userdetailsgb.cpp(60) : warning C4273: 'UserDetailsGB::qt_metacall': Inkonsistente DLL-Bindung.
1> d:\development\projects\test_mainwindow\debug\../userdetailsgb.h(52): Siehe vorherige Definition von 'qt_metacall'
1>Code wird generiert...
1>Das Buildprotokoll wurde unter "file://d:\Development\Projects\Test_MainWindow\debug\Buil dLog.htm" gespeichert.
1>testApp - 1 Fehler, 4 Warnung(en)
========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========


Did you add Q_EXPORT_PLUGIN2(customwidgetplugin, MyCustomWidget) at the bottom of userdetailsgbpluginglobal.cpp?

I have included this Qt macro in my userdetailsgbplugin.cpp file and NOT in the userdetailsgbpluginglobal.cpp file (which I actually do not have, the userdetailsgbpluginglobal.h file is just a header file where I do declare my #defines, nothing else.)

Any other ideas?

Many thanks!

high_flyer
30th May 2007, 09:08
I don't think this will solve the problem, but you must add thead support in CONFIG in the pro file.
Oh, and try a release version.

big4mil
30th May 2007, 17:33
I don't think this will solve the problem, but you must add thead support in CONFIG in the pro file.
Oh, and try a release version.
this does not help. I still get the same errors.

I have attached two projects. userdetailsgb will create the qt designer plugin and the test_mainwindow project will use the plugin on a simple main window. So please, if you have time to make a quick test on your system, that would be great.
(MSVC 2005 Express, Windows XP, Qt 4.2.3)

Many thanks for your help.
Best regards
big4mil