How to conditionally use PropertyChanges in State?
Unsolved
QML and Qt Quick
-
I want to change a property of a
Loader
when it is active and ignore thePropertyChanges
when theLoader
doesn't load. Here is the code.import QtQuick Window { visible: true Item { anchors.fill: parent states: [ State { when: mouseArea.containsMouse PropertyChanges { target: loader.item text: "world" } } ] Loader { id: loader anchors.fill: parent active: false // some condition sourceComponent: Text { text: "hello" } } } MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true } }
However, when I directly use
loader.item.text: "world"
, it shows an error: QML PropertyChanges: Cannot assign to non-existent property "text". So, how to avoid such an error whenLoader
doesn't load?