Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDESIGNER_WIDGET_EXPORT causes dll linkage errors
Forum Updated to NodeBB v4.3 + New Features

QDESIGNER_WIDGET_EXPORT causes dll linkage errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 552 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mourke
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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)

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Follow the guide lines shown in Creating Shared Libraries with regards to the macros.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved