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. Q_PROPERTY from official doc creating error. Why?

Q_PROPERTY from official doc creating error. Why?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 678 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by bogong
    #1

    Hello!
    Just got confused about this code from official docs:

    QObject *object = ...
    const QMetaObject *metaobject = object->metaObject();
    int count = metaobject->propertyCount();
    for (int i=0; i<count; ++i) {
        QMetaProperty metaproperty = metaobject->property(i);
        const char *name = metaproperty.name();
        QVariant value = object->property(name);
        ...
    }
    

    There are error like this
    0_1564669583108_Screenshot 2019-08-01 at 17.25.44.png

    The question why?
    I am using qt 5.12.4 and Qt Creator 4.9.2

    ODБOïO JKSHJ 2 Replies Last reply
    0
    • B bogong

      Hello!
      Just got confused about this code from official docs:

      QObject *object = ...
      const QMetaObject *metaobject = object->metaObject();
      int count = metaobject->propertyCount();
      for (int i=0; i<count; ++i) {
          QMetaProperty metaproperty = metaobject->property(i);
          const char *name = metaproperty.name();
          QVariant value = object->property(name);
          ...
      }
      

      There are error like this
      0_1564669583108_Screenshot 2019-08-01 at 17.25.44.png

      The question why?
      I am using qt 5.12.4 and Qt Creator 4.9.2

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @bogong hi
      try #include <QMetaProperty>

      1 Reply Last reply
      6
      • B bogong

        Hello!
        Just got confused about this code from official docs:

        QObject *object = ...
        const QMetaObject *metaobject = object->metaObject();
        int count = metaobject->propertyCount();
        for (int i=0; i<count; ++i) {
            QMetaProperty metaproperty = metaobject->property(i);
            const char *name = metaproperty.name();
            QVariant value = object->property(name);
            ...
        }
        

        There are error like this
        0_1564669583108_Screenshot 2019-08-01 at 17.25.44.png

        The question why?
        I am using qt 5.12.4 and Qt Creator 4.9.2

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @bogong said in Q_PROPERTY from official doc creating error. Why?:

        The question why?

        The error message tells you why: "incomplete return type 'QMetaProperty'" means you're missing the header for QMetaProperty.

        @LeLev gave the correct solution.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        4
        • B Offline
          B Offline
          bogong
          wrote on last edited by bogong
          #4

          @LeLev @JKSH This is the first that I've been checking. But it's included and showing that couldn't find it. After last update of Qt Creator on Mac sometimes it's showing that could not find something from Qt. Only reconfiguring project helping.

          jsulmJ 1 Reply Last reply
          0
          • B bogong

            @LeLev @JKSH This is the first that I've been checking. But it's included and showing that couldn't find it. After last update of Qt Creator on Mac sometimes it's showing that could not find something from Qt. Only reconfiguring project helping.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #5

            @bogong Please show how you include it.
            Also, you need this in your pro file:

            QT += core
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • B Offline
              B Offline
              bogong
              wrote on last edited by bogong
              #6

              @jsulm @JKSH @LeLev Thanks everyone. I don't know what was there but clearing cache and reconfiguring project solved the problem. We are working together with few developers they are working on Linux and Windows. They do not have the same problems after update. It's not the first time when clearing cache and deleting *.pro.user file solving this kind of troubles.

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

                Hi,

                .pro.user files are machine specific, you should not have them in your version control system.

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

                B 1 Reply Last reply
                1
                • SGaistS SGaist

                  Hi,

                  .pro.user files are machine specific, you should not have them in your version control system.

                  B Offline
                  B Offline
                  bogong
                  wrote on last edited by bogong
                  #8

                  @sgaist I know it perfectly. And there are nothing about what you've been writing. The problem is in updates only on MacOS, but I do not know what in precise.

                  Just got the same trouble on creating new project from scratch. For now Qt Creator do not see QtQuick.Window 2.120_1564749938834_Screenshot 2019-08-02 at 15.44.25.png
                  There are everything from default of Qt Creator Wizard.
                  Sometimes it's do not see something random after updates. And only on MacOS.
                  But in menu it's appearing
                  0_1564750112249_Screenshot 2019-08-02 at 15.48.04.png
                  The same situation might be for any includes.

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    bogong
                    wrote on last edited by bogong
                    #9

                    I don't know why but it's working when switched OFF QtCreator-> help -> About Plugins->ClangCodeModel
                    The same issue was before https://forum.qt.io/topic/100408/qt-creator-strange-behaviour-how-to-fix-it/11 and it's happening only on MacOS

                    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