[Qt-qml] Flickable height
Adriano Rezende
adriano.rezende at openbossa.org
Thu Sep 23 17:14:55 CEST 2010
Hi,
On Thu, Sep 23, 2010 at 9:54 AM, <thierry.bastian at nokia.com> wrote:
> import Qt 4.7
> import Qt.labs.gestures 2.0
>
> Flickable {
> width: 380; height: 600
> contentHeight : 900
>
> Rectangle {
> color: "red"
> x: 0; y:0; width: parent.width; height: (parent.height/2)
> }
> }
> Here I would expect my rectangle to be 300px tall (height/2) but I get 450px
> (contentHeight/2). Is that a bug?
This happens because items declared as children of Flickable are
automatically parented to flickable's contentItem (so, parent.height
== flickable.contentItem.height). The flickable width/height controls
the flickable viewport size, while contentWidth/contentHeight controls
the size of the flickable.contentItem, which is inside this viewport.
I agree that this may be confusing.
If you want to bind to the flickable height you can do like below:
Flickable {
id: flickable
width: 380
height: 600
contentHeight: 900
Rectangle {
color: "red"
width: parent.width
height: (flickable.height / 2)
}
}
Br,
Adriano
More information about the Qt-qml
mailing list