Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.7.1, 5.0.0
-
None
-
Ubuntu 10.10, 32bit
Qt branch 4.7, commit 896cd4bd08181ad16ad9cee6d2aaa1844a4f06d3
Description
I have two files and I want to change properties of the anchors group property:
import QtQuick 1.0 Rectangle { property alias textbox: textbox_ property variant textboxVariant: textbox_ id: rect width: 100 radius: 12 height: 50 color: "#dedede" opacity: 0.55 Text { property bool iAmAProperty: true id: textbox_ text: "hello world!" anchors.bottom: parent.bottom anchors.left: parent.left anchors.bottomMargin: iAmAProperty ? 20 : -20 //anchors.bottomMargin: 20 // if there is no binding, setting grouped prop values work anchors.leftMargin: 20 } }
I initialize this file with the following code:
TextboxRect { id: rect textbox.anchors.leftMargin: 0 // works, not binding textbox.anchors.bottomMargin: 0 // does not work, TextboxRect has binding in its value //textboxVariant.anchors.bottomMargin: 0 // this works }
The problem is clear: while the text in the rect should be positioned on bottom left corner, it's positioned to the left and center. That is, the anchors.bottom property value does not change during initialization. As commented out in the code, setting the property does work if there is no binding in the value. With a binding in component's grouped property declaration, the value cannot be changed through an aliased property.
Using the variant imperatively works, e.g.
rect.textbox.anchors.bottomMargin = 0
works fine.