Unsolved Strange qml property evaluation behaviour
-
Hello guys, I have the following QtQuick snippet showing behavior I don't quite understand:
import QtQuick 2.5 Rectangle { id: rect width: 300 height: 300 property int property1: height property int property2: width Rectangle { height: rect.property1 width: { console.log("rect width is ", rect.property2); return rect.property2; } } }
So, I am binding rect.property2 to rect.width which is 300. I would expect the console log to appear once saying "rect width is 300", but it is output twice: "rect width is 0" and "rect width is 300". As a user, based on the above code I am not expecting rect.width to be zero (this behaviour is actually breaking the logic in my current project). But if I comment out the line "height: rect.property1" I see the expected output . Any ideas how to explain this?