Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [4.7] QML properties load order
Forum Updated to NodeBB v4.3 + New Features

[4.7] QML properties load order

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 4.8k 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.
  • B Offline
    B Offline
    bunjee
    wrote on last edited by
    #1

    Hey guys,

    Is there a way to specify the "first load" order for QML properties.

    For instance:

    @Item {
    loadMeFirst: 1

     width: 200
     height: 200
    

    }@

    When calling create QDeclarativeComponent::create(QDeclarativeContext * context = 0), I want "setLoadMeFirst" to be called before "setWidth" and "setHeight".

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      In general there isn't really a way to do this (part of being 'declarative' is that ordering of assignments shouldn't usually matter). Can you say any more about why you would like to do this? Is it for a custom C++ component (in which case deriving from QDeclarativeParserStatus might be helpful)?

      That said, you might be able to exploit the engines overall ordering to achieve what you are after:

      1. Literal assignments are performed first
      2. Bindings are evaluated next
      3. Component.onCompleted is called

      For example, forcing width/height to be a binding should cause loadMeFirst to be assigned first (assuming these trivial bindings aren't optimized away to literal assignments):
      @Item {
      loadMeFirst: 1

       width: {200}
       height: {200}
      

      }@

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bunjee
        wrote on last edited by
        #3

        Thanks mbrasser.

        I'm trying to do an "Application" C++ QML object and a property that contains plugins to be loaded at runtime.

        Obviously I need to load the plugins before anything else. Guess if QML does not allow this I might do a "pluginspec" file.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          Hi,

          Have you looked at "QDeclarativeParserStatus":http://doc.qt.nokia.com/4.7/qdeclarativeparserstatus.html at all? Many of the built in visual items use this to delay doing any "real work" until all of the properties have been set (at which point componentComplete() is called). You might similarly be able to avoid doing anything requiring the plugins until componentComplete() is called.

          Michael

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bunjee
            wrote on last edited by
            #5

            @mbrasser : Yep I've looked at QDeclarativeParserStatus.

            My QML Object I'm trying to operate with is a QObject not a QDeclarativeItem.

            So I guess it complicates things a little bit ? Or maybe I missed something ?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbrasser
              wrote on last edited by
              #6

              Hi,

              Working with a direct QObject-derived subclass rather than a QDeclarativeItem-derived subclass shouldn't be a problem (the engine itself knows nothing about QDeclarativeItem; to the engine QDeclarativeItem is simply another QObject with properties). Note that QDeclarativeParserStatus is an interface that is meant to be multiply inherited from (i.e. you would inherit from both QObject and QDeclarativeParserStatus to use it).

              Regards,
              Michael

              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