How to set a "instant" value instead of a relative value of a property? Simple example...
-
rect2 width and height must be half of its parent width and height. But I want that just at the beginning. If the user resizes the window, I don't want the rect2 to recalculate his width and height based on its parent size. Example:
@Rectangle {
id: rect;
width: 360;
height: 360;
color: "black";Rectangle { id: rect2; width: rect.width*0.5; height: rect.height*0.5; anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter; color: "white"; }
}@
In this example, I want the rect2 to be "forever" 180 x 180.
PS: I'm a Qt Programmer. Beginner at QtQuick. -
I got it, guys. When we set
@width: rect.width * 0.5;@
is happening a binding. Not an assignment. What I should do to assign the value:
@Component.onCompleted: {
width = rect.width * 0.5;
}@