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. QT designer with custom widget plugin setting incorrect qualified enum property name
Forum Update on Monday, May 27th 2025

QT designer with custom widget plugin setting incorrect qualified enum property name

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 308 Views
  • 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.
  • H Offline
    H Offline
    hippos
    wrote on 5 Oct 2023, 11:27 last edited by
    #1

    Hi all I am seeing some strange outcomes when using QT designer and a custom widget plugin.

    I have declared an enum like so. I originally tried with the enum inside a class that extended QObject (while using the Q_ENUM macro) and the results are the same.

    namespace SettingsTypes
    {
        Q_NAMESPACE
    
        enum class Network {
            NETWORK_IP,
            NETWORK_PORT
        };
        Q_ENUM_NS(Network)
    }
    

    My widget declares the enum as a property.

    class QDESIGNER_WIDGET_EXPORT SettingsWidget : public QLineEdit {
    Q_OBJECT
        Q_PROPERTY(SettingsTypes::Network setting READ getSetting WRITE setSetting)
    
    public:
        explicit SettingsWidget(QWidget *parent = nullptr);
    
        SettingsTypes::Network getSetting();
        void setSetting(SettingsTypes::Network s);
    
    
    public slots:
        void valueChanged(const QString &);
    
    private:
        SettingsTypes::Network setting;
    };
    

    At this point everything works great, the widget shows up in designer. I can even use the widget in my main app.

    The issue I am facing is when I select my settings property value in designer (which shows up correctly with my list of enum values) and then build the app, I see this.

     error: 'NETWORK_IP' is not a member of 'SettingsTypes'; did you mean 'SettingsTypes::Network::NETWORK_IP'?
    

    Which is happening from the designer generated code.

    settingswidget->setSetting(SettingsTypes::NETWORK_IP);
    

    It appears to be messing up the qualified name for the enum. If I change the generated code to SettingsTypes::Network::NETWORK_IP everything compiles and is happy.

    Any ideas how designer has gotten confused? I have tried to call qRegisterMetaTypeSettingsTypes::Network("SettingsTypes::Network"); in the widgetplugin constructor but that didn't make a difference either. I am using CLion and CMake if you think that could have an effect.

    C 1 Reply Last reply 5 Oct 2023, 15:36
    0
    • H hippos
      5 Oct 2023, 11:27

      Hi all I am seeing some strange outcomes when using QT designer and a custom widget plugin.

      I have declared an enum like so. I originally tried with the enum inside a class that extended QObject (while using the Q_ENUM macro) and the results are the same.

      namespace SettingsTypes
      {
          Q_NAMESPACE
      
          enum class Network {
              NETWORK_IP,
              NETWORK_PORT
          };
          Q_ENUM_NS(Network)
      }
      

      My widget declares the enum as a property.

      class QDESIGNER_WIDGET_EXPORT SettingsWidget : public QLineEdit {
      Q_OBJECT
          Q_PROPERTY(SettingsTypes::Network setting READ getSetting WRITE setSetting)
      
      public:
          explicit SettingsWidget(QWidget *parent = nullptr);
      
          SettingsTypes::Network getSetting();
          void setSetting(SettingsTypes::Network s);
      
      
      public slots:
          void valueChanged(const QString &);
      
      private:
          SettingsTypes::Network setting;
      };
      

      At this point everything works great, the widget shows up in designer. I can even use the widget in my main app.

      The issue I am facing is when I select my settings property value in designer (which shows up correctly with my list of enum values) and then build the app, I see this.

       error: 'NETWORK_IP' is not a member of 'SettingsTypes'; did you mean 'SettingsTypes::Network::NETWORK_IP'?
      

      Which is happening from the designer generated code.

      settingswidget->setSetting(SettingsTypes::NETWORK_IP);
      

      It appears to be messing up the qualified name for the enum. If I change the generated code to SettingsTypes::Network::NETWORK_IP everything compiles and is happy.

      Any ideas how designer has gotten confused? I have tried to call qRegisterMetaTypeSettingsTypes::Network("SettingsTypes::Network"); in the widgetplugin constructor but that didn't make a difference either. I am using CLion and CMake if you think that could have an effect.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 5 Oct 2023, 15:36 last edited by
      #2

      I'm not sure if 'enum class' is supported here. Maybe search the bug report system and/or create a bug for it.

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

      H 1 Reply Last reply 5 Oct 2023, 21:00
      1
      • C Christian Ehrlicher
        5 Oct 2023, 15:36

        I'm not sure if 'enum class' is supported here. Maybe search the bug report system and/or create a bug for it.

        H Offline
        H Offline
        hippos
        wrote on 5 Oct 2023, 21:00 last edited by
        #3

        @Christian-Ehrlicher damn, you are correct. Making it an Enum fixed it. Thanks!

        1 Reply Last reply
        1
        • H hippos has marked this topic as solved on 5 Oct 2023, 21:00

        3/3

        5 Oct 2023, 21:00

        • Login

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