[Qt-qml] Flickable height

thierry.bastian at nokia.com thierry.bastian at nokia.com
Fri Sep 24 12:07:34 CEST 2010



> -----Original Message-----
> From: ext Adriano Rezende [mailto:adriano.rezende at openbossa.org]
> Sent: jeudi 23 septembre 2010 17:15
> To: Bastian Thierry (Nokia-MS-Qt/Oslo)
> Cc: qt-qml at trolltech.com
> Subject: Re: [Qt-qml] Flickable height
> 
> 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


Hi,

I basically was trying to do something and it was not obvious that I was doing something wrong. I found the workaround anyway. So no big deal. It is just not straight forward.

Br,
Thierry




More information about the Qt-qml mailing list