Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Property change notification



  • 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



  • 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.


Log in to reply