QDESIGNER_WIDGET_EXPORT causes dll linkage errors
-
I am trying to create a custom button class with an enum that change be changed from inside Qt Designer.
I have added the QDESIGNER_WIDGET_EXPORT macro to my class definition so it looks like this:
#ifndef TITLEBARBUTTON_H #define TITLEBARBUTTON_H #include <QPushButton> #include <QtUiPlugin/QDesignerExportWidget> class QDESIGNER_WIDGET_EXPORT TitleBarButton : public QPushButton { Q_OBJECT Q_PROPERTY(Type type READ type WRITE setType) public: enum Type { Minimize, Maximize, Restore, Close }; Q_ENUM(Type) Type type() const { return m_type; } void setType(const Type &type); TitleBarButton(QWidget *parent); ~TitleBarButton(); private: Type m_type; }; #endif // TITLEBARBUTTON_H
I am using Visual Studio so I have checked the UI Tools module in the QT VS Tools > Qt Project Settings > Qt Modules options menu.
When I go to build the project I get errors about inconsistent dll linkage. Upon further investigation this is caused by using
__declspec(dllimport)
instead of__declspec(dllexport)
. In Qt this is done depending on a QDESIGNER_EXPORT_WIDGETS macro being defined. Replacing QDESIGNER_WIDGET_EXPORT with Q_DECL_EXPORT allows my project to successfully build but I cannot see my enum in the properties inspector inside Qt designer.What am I doing wrong?
-
@mourke said in QDESIGNER_WIDGET_EXPORT causes dll linkage errors:
QDESIGNER_EXPORT_WIDGETS
Don't use it since it's not meant to be used this way (as you've noticed)
-
Hi,
Follow the guide lines shown in Creating Shared Libraries with regards to the macros.