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. Display comboBox like list with Q_PROPERTY
Forum Updated to NodeBB v4.3 + New Features

Display comboBox like list with Q_PROPERTY

Scheduled Pinned Locked Moved General and Desktop
18 Posts 4 Posters 8.9k 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.
  • S Offline
    S Offline
    shootstar
    wrote on last edited by
    #8

    hi raven-worx, thank you for your replay!
    i have use an enum type ,like "enum ParamTypeList{...}", but it also not solve my problem, and if the property defined as enum, it will not be displayed in the property page.

    thanks,
    shootstar

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #9

      [quote author="shootstar" date="1370589776"]hi raven-worx, thank you for your replay!
      i have use an enum type ,like "enum ParamTypeList{...}", but it also not solve my problem, and if the property defined as enum, it will not be displayed in the property page.
      [/quote]
      i think you also have to specify the "Q_ENUMS macro":http://qt-project.org/doc/qt-4.8/qobject.html#Q_ENUMS in your class definition so Qt knows about it

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shootstar
        wrote on last edited by
        #10

        well, i specify the Q_ENUMS macro, like "Q_ENUMS(ParamTypeList)",and it has passes the compiler and linker. But the property does't display in the property in the property page still.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #11

          just to make sure: you subclass QObject (or a class which inherits QObject) and you have Q_OBJECT macro specified?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            shootstar
            wrote on last edited by
            #12

            my .h file just like this:
            class AxisCoord : public QWidget, public QAxBindable
            {
            Q_OBJECT
            Q_ENUMS(ParamTypeList)
            Q_PROPERTY( QString nctype READ GetType WRITE SetType)
            Q_PROPERTY( int value READ value WRITE setValue )
            Q_PROPERTY(ParamTypeList ParamType READ getParamType WRITE setParamType)

            public:
            AxisCoord(QWidget *parent = 0);

            QString GetType() const;
            int value() const;
            enum ParamTypeList
            {
            TYPE1,
            TYPE2,
            TYPE3
            };

            ParamTypeList getParamType() const;
            ... //other code
            }

            1 Reply Last reply
            0
            • S Offline
              S Offline
              shootstar
              wrote on last edited by
              #13

              my .h file just like this:
              @class AxisCoord : public QWidget, public QAxBindable
              {
              Q_OBJECT
              Q_ENUMS(ParamTypeList)
              Q_PROPERTY( QString nctype READ GetType WRITE SetType)
              Q_PROPERTY( int value READ value WRITE setValue )
              Q_PROPERTY(ParamTypeList ParamType READ getParamType WRITE setParamType)

              public:
              AxisCoord(QWidget *parent = 0);

              QString GetType() const;
              int value() const;

              enum ParamTypeList
              {
              TYPE1,
              TYPE2,
              TYPE3
              };

              ParamTypeList getParamType() const;

              QComboBox getCombobox() const;

              ...//other code
              @

              1 Reply Last reply
              0
              • raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #14

                hmm...please clean your project, rerun qmake and try again.

                I don't think that i makes a difference but you can give it also a try: specify the Q_ENUMS macro after the Q_PROPERTY macros. Like in this "example":http://qt-project.org/doc/qt-4.8/properties.html#a-simple-example.

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  shootstar
                  wrote on last edited by
                  #15

                  thank you very much! when i clean my project, and add the actviex again, the property has displayed at last. I'm really very grateful to you!

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    shootstar
                    wrote on last edited by
                    #16

                    hi, raven-worx, i encounter a new problem. now, the property can be displayed, but when i modify the QAxWidget property which displayed in comboBox(include defined property), as:
                    @ //ui_test_active.h
                    axWidget->setProperty("FocusPolicy", QVariant(QAxWidget::NoFocus));
                    axWidget->setProperty("ParamType", QVariant(QAxWidget::TYPE2));
                    axWidget->setProperty("cursor", QVariant(QAxWidget::UpArrowCursor));
                    @
                    you know, the "FocusPolicy" and "cursor" property are the defualt property, only the "ParamType" is the new property. but when i build the project, there are errors, as:
                    @1>E:\HNC11\test_active\test_active\GeneratedFiles\ui_test_active.h(45): error C2039: 'NoFocus' : is not a member of 'QAxWidget'
                    1> d:\qt\qt5.0.2\5.0.2\msvc2010\include\activeqt\qaxwidget.h(59) : see declaration of 'QAxWidget'
                    1>E:\HNC11\test_active\test_active\GeneratedFiles\ui_test_active.h(45): error C2065: 'NoFocus' : undeclared identifier
                    1>E:\HNC11\test_active\test_active\GeneratedFiles\ui_test_active.h(46): error C2039: 'TYPE2' : is not a member of 'QAxWidget'
                    1> d:\qt\qt5.0.2\5.0.2\msvc2010\include\activeqt\qaxwidget.h(59) : see declaration of 'QAxWidget'
                    1>E:\HNC11\test_active\test_active\GeneratedFiles\ui_test_active.h(46): error C2065: 'TYPE2' : undeclared identifier
                    1>E:\HNC11\test_active\test_active\GeneratedFiles\ui_test_active.h(48): error C2039: 'UpArrowCursor' : is not a member of 'QAxWidget'
                    1> d:\qt\qt5.0.2\5.0.2\msvc2010\include\activeqt\qaxwidget.h(59) : see declaration of 'QAxWidget'
                    1>E:\HNC11\test_active\test_active\GeneratedFiles\ui_test_active.h(48): error C2065: 'UpArrowCursor' : undeclared identifier@
                    i have no idea to solve those error, can you help?

                    1 Reply Last reply
                    0
                    • raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #17

                      [quote author="shootstar" date="1370658202"]
                      you know, the "FocusPolicy" and "cursor" property are the defualt property, only the "ParamType" is the new property. but when i build the project, there are errors[/quote]

                      the compiler error says it all: "error C2039: 'NoFocus' : is not a member of 'QAxWidget'"
                      Your enum values are not defined in QAxWidegt but in Qt namespace. So use Qt::NoFocus and Qt::UpArrowCursor.

                      And btw. why do you use to set these properties with with the setter for dynamic properties (i mean the setProperty() method)? I think there is nothing wrong with this code, but it is more error prone and there are qwidget setters available.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        shootstar
                        wrote on last edited by
                        #18

                        thank you for your help!
                        the code which in "ui_test_active.h" is automatically created by the system, i just modify the activeX property in Qt designer, then the system automatically generates those codes ("ui_test_active.h" file), so how can i do? whether is there some wrongs with my system configuration?

                        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