[Interest] QML: How to set verticalCenterOffset...

Dmitry Volosnykh dmitry.volosnykh at gmail.com
Sun Aug 16 21:06:46 CEST 2015


Your issue is the result of the fact that ListView has zero height (just
print height of your list in Component.onCompleted and onHeightChanged
handlers). While it gets correctly positioned in the middle of the window,
its children go right below the middle line. You need a way to set
ListView's height to the height of the images. Using childrenRect.height
did not work for me. In your case, assuming all images are of the same
size, you may want to set list's height manually.

On Sun, Aug 16, 2015 at 9:47 PM, Igor Mironchik <igor.mironchik at gmail.com>
wrote:

> In the attachment...
>
> On 16.08.2015 21:40, Dmitry Volosnykh wrote:
>
> You'd better provide your example so that we could run it with qmlscene.
>
> On Sun, Aug 16, 2015 at 9:08 PM, Igor Mironchik <igor.mironchik at gmail.com>
> wrote:
>
>> Hi,
>>
>> I'm trying to center ListView in a Rectangle.
>>
>> I do:
>>
>> anchors.centerIn: parent
>>
>> But it moves ListView under the real center, so I need to add negative
>> verticalCenterOffset.
>>
>> I've tried in ListView:
>>
>> anchors.verticalCenterOffset: - height / 2.0
>>
>> But it doesn't work. If I set verticalCenterOffset without calculations,
>> i.e. real number then all is ok...
>>
>> How can I solve the problem?
>>
>> --
>> Best Regards,
>> Igor Mironchik.
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
> --
> Best Regards,
> Igor Mironchik.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150816/c22d8c1c/attachment.html>


More information about the Interest mailing list