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. property / setProperty and iterating...

property / setProperty and iterating...

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 355 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have a lot of properties set using setProperty in my application. I can retrieve the properties calling property and I can see they are stored correctly. I want to create a generic loop to iterate through all the properties so I wrote:

    const QMetaObject* cpobjMetaObject((QMetaObject*)metaObject());
    for( int i=cpobjMetaObject->propertyOffset()
            ;i<cpobjMetaObject->propertyCount()
            ;i++ ) {
            QMetaProperty objProperty(cpobjMetaObject->property(i));
    qDebug() << "HACK";
    }
    

    The debug line is just there so I can set a breakpoint in the debugger in the loop, I have tested using debugger and can see that both propertyOffset and propertyCount both return 66.

    This isn't correct, what am I missing?

    Kind Regards,
    Sy

    KroMignonK 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I have a lot of properties set using setProperty in my application. I can retrieve the properties calling property and I can see they are stored correctly. I want to create a generic loop to iterate through all the properties so I wrote:

      const QMetaObject* cpobjMetaObject((QMetaObject*)metaObject());
      for( int i=cpobjMetaObject->propertyOffset()
              ;i<cpobjMetaObject->propertyCount()
              ;i++ ) {
              QMetaProperty objProperty(cpobjMetaObject->property(i));
      qDebug() << "HACK";
      }
      

      The debug line is just there so I can set a breakpoint in the debugger in the loop, I have tested using debugger and can see that both propertyOffset and propertyCount both return 66.

      This isn't correct, what am I missing?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #2

      @SPlatten said in property / setProperty and iterating...:

      This isn't correct, what am I missing?

      You are mixing up QMetaObject properties (which are static, created by MOC) and QObject dynamic properties!
      What you are looking for is QObject::dynamicPropertyNames()

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      SPlattenS 1 Reply Last reply
      2
      • KroMignonK KroMignon

        @SPlatten said in property / setProperty and iterating...:

        This isn't correct, what am I missing?

        You are mixing up QMetaObject properties (which are static, created by MOC) and QObject dynamic properties!
        What you are looking for is QObject::dynamicPropertyNames()

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @KroMignon , thank you!

        Kind Regards,
        Sy

        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