-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.11.1
-
None
If you press the "Reset before set" button you get an error, even though you expect that it will change the label text.
qrc:/main.qml:27: ReferenceError: label is not defined
I think it makes sense to keep the references working until the whole code block finishes.
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Window {
visible: true
width: 640
height: 480
ColumnLayout {
anchors.fill: parent
Label {
id: label
text: "This text should change"
}
ListView {
id: listview
Layout.fillWidth: true
Layout.fillHeight: true
model: 1
delegate: Row {
Button {
text: "Reset before set (doesn't work)"
onClicked: {
listview.model = 0
label.text = "Changed"
}
}
Button {
text: "Set before reset (works)"
onClicked: {
label.text = "Changed"
listview.model = 0
}
}
}
}
}
}