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. Question about order of execution by property change.

Question about order of execution by property change.

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 905 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.
  • C Offline
    C Offline
    coldmund
    wrote on last edited by
    #1

    my code is like below.

    ClassA.qml

    @
    Rectangle {
    ClassB { id:b }
    MouseArea {
    onClicked: {
    b.propX = false;
    doSomething(); // A
    }
    }
    }
    @

    ClassB.qml

    @
    Rectangle {
    property bool propX: true
    onPropXChanged: doAnything(); // B
    Rectangle {
    visible: propX
    onVisibleChanged: doWhatever(); // C
    }
    }
    @

    if I click the mousearea of ClassA, what's the order of excution of the A~C?

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

      For me it would be C to A,

      b.propX turns to false so it triggers doWhatever() which is topmost Item then triggers doAnything() and finally doSomething since it comes after b.propX = false.

      To make sure you could have your functions as followed :

      @function doSomething()
      {
      console.log( "doSomething" )
      }

      function doAnything()
      {
      console.log( "doAnything" )
      }

      function doWhatever()
      {
      console.log( "doWhatever" )
      }@

      This way you can actually see what is the order and if it is always the same

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        I don't know the internal workings of the engine enough to answer with confidence. My opinion is you should not depend on the order being the same: those things are processed by meta object calls, it might happen - for example - that the order is different on another machine, or on a different operating system.

        There was a splendid series of blogs about QML engine on KDAB's blog. "A very interesting read":http://www.kdab.com/qml-engine-internals-part-1-qml-file-loading/.

        (Z(:^

        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