[Interest] QML: How to set verticalCenterOffset...
Igor Mironchik
igor.mironchik at gmail.com
Sun Aug 16 20:47:13 CEST 2015
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 <mailto: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 <mailto: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/27f554a3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: e.png
Type: image/png
Size: 317 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150816/27f554a3/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i.png
Type: image/png
Size: 327 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150816/27f554a3/attachment-0001.png>
-------------- next part --------------
import QtQuick 2.0
Rectangle {
id: root
color: "red"
width: 640
height: 480
ListModel {
id: sampleModel
Component.onCompleted: {
sampleModel.append( { "imagePath" : "file:/home/igor/Tmp/Center/w.png"} )
sampleModel.append( { "imagePath" : "file:/home/igor/Tmp/Center/i.png"} )
sampleModel.append( { "imagePath" : "file:/home/igor/Tmp/Center/n.png"} )
sampleModel.append( { "imagePath" : "file:/home/igor/Tmp/Center/n.png"} )
sampleModel.append( { "imagePath" : "file:/home/igor/Tmp/Center/e.png"} )
sampleModel.append( { "imagePath" : "file:/home/igor/Tmp/Center/r.png"} )
}
}
Component {
id: delegateItem
Image { source: imagePath }
}
ListView {
id: winner_message
anchors.centerIn: parent
anchors.verticalCenterOffset: - height / 2.0
orientation: ListView.Horizontal
model: sampleModel
delegate: delegateItem
width: childrenRect.width
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: n.png
Type: image/png
Size: 362 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150816/27f554a3/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: r.png
Type: image/png
Size: 370 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150816/27f554a3/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: w.png
Type: image/png
Size: 388 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150816/27f554a3/attachment-0004.png>
More information about the Interest
mailing list