Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Property change notification

    QML and Qt Quick
    2
    2
    93
    Loading More Posts
    • 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.
    • X
      xargs1 last edited by xargs1

      I found something unexpected with onChange signals. If I have

      property int foo: 42
      onFooChanged: console.log(foo);
      

      This works as expected and I see nothing in the log unless foo is modified. But if I have

      readonly property int init: 42
      property int foo: init
      onFooChanged: console.log(foo);
      

      I will get a change notification in the log when the application starts. Is this expected behavior? Can it be changed?

      Qt 5.12.7

      1 Reply Last reply Reply Quote 0
      • 6thC
        6thC last edited by

        Well, you could bind to changed after | onCompleted?

        I wouldn't get too hung up on just this if I found out unless it is affecting behaviour or functionality. I do act quite defensively to references to c++ null refs etc in qml and really act to cut rebinds away entierly.

        To assist me greatly do this, early in main I turn on qt.qml.binding.removal.info category logging. e.g:

        QLoggingCategory::setFilterRules(QStringLiteral("qt.qml.binding.removal.info  =true\n"));
        

        That way only the qt/qml objects produce rebind warning or if mine, only very determined rebinds, which I plan on eventually clearing those (currently just one) too.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post