Unexpected property value in Repeater in Qt 5.15.2
-
The final value of fooProperty seems to depend on whether fooProperty is referenced in onVisibleChanged. Does anyone understand what's leading to this behaviour?
This changed when we upgraded from Qt 5.13 to 5.15.2.
Main.qml
import Qt.labs.platform 1.1 import QtQuick 2.12 import QtQuick.Window 2.3 import QtQuick.Controls 2.5 import QtGraphicalEffects 1.0 import QtQuick.Layouts 1.3 QQuickWindow { id: qQuickWindowInstance Repeater { model: 5 Item { id: fooItem FooElement { id: fooElementInstance fooProperty: index fooVisible: true } Component.onCompleted: { // This is supposed to log 0 1 2 3 4, not -1 -1 -1 -1 -1 // fooProperty doesn't update with value of index if there is an onVisibleChanged function in fooElementInstance that refers to fooProperty console.log("Main log fooProperty: ", fooElementInstance.fooProperty) } } } }
FooElement.qml:
import QtQuick 2.12 import QtGraphicalEffects 1.13 import QtQuick.Controls 2.5 Item { id: fooElement property int fooProperty: -1 property alias fooVisible: fooRectangle.visible Rectangle { id: fooRectangle visible: false onVisibleChanged: { // Comment the below out to have fooProperty take the correct value console.log("FooElement log fooProperty: ", fooElement.fooProperty) } } }