Important: Please read the Qt Code of Conduct -

QML binding executed before QObject connection

  • Hi,

    I saw some strange behaviour on the Qt project I'm working on (5.12.6, OSX), but I don't know if this is by design, or not.
    Lets have the following registered QObject types:
    Class P

    • with property p of type G

    Class A

    • with a constant property x of type *P (exposed as a pointer)
    • after creating x in the constructor, it creates a connection between x.p change notification and one of its private slot (let's call it S)

    Class B

    • with property b of type G

    On QML side:

    • there is logic to alter A.x.p
    • B.b is bound to A.x.p

    My expectation would be that when A.x.p is changed, A::S() would be called first (since it was the first connection made to property x), and afterwards the binding made in QML to B.b, but it seems they are called reverse order. Threading should not be an issue here.

    Is it expected that QML bindings are performed before QObject connections? I couldn't find anywhere in the documentation this kind of information.

    Sorry for posting this question without any snippets, will follow up with an example if something is still unclear.

Log in to reply