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 Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 385 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 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.

    Christian EhrlicherC 1 Reply Last reply
    0
    • H hippos

      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.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      1
      • Christian EhrlicherC Christian Ehrlicher

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

        • Login

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