Dear all,
I’m experiencing a unexpected behavior:
I have a ListView in QML that display data from a ListModel.
The dimension of ListView is set in such a way that only one element delegate 
is display at time.
When I configure the ListView to be Vertical, then the first item displayed is 
the first item on the ListModel.
But when I configure the ListView to be Horizontal, then the first item 
displayed is not the first item on the ListModel … but one in the middle.
Why ??
Forcing the property currentIndex to 0 do not solve the problem.
Calling positionViewAtBeginning do not solve the problem :-(

What else I can do ?

// Code of ListView:
                ListView {
                        id: listHistory
                        anchors.centerIn: parent
                        height: parent.height
                        width: parent.width-previous.width-next.width
                        clip: true
                        orientation: ListView.Horizontal
                        snapMode: ListView.SnapToItem
                        highlightRangeMode: ListView.StrictlyEnforceRange
                        onCurrentIndexChanged: console.log( "Current Index: 
"+currentIndex )
                        model: modelHistory
                        delegate: Item {
                                width: listHistory.width
                                height: listHistory.height
                                Text {
                                        width: parent.width
                                        anchors.bottom: parent.verticalCenter
                                        color: "white"
                                        font.pixelSize: 8.5*mm
                                        minimumPixelSize: 4*mm
                                        fontSizeMode: Text.Fit
                                        horizontalAlignment: Text.AlignHCenter
                                        text: year
                                }
                                Text {
                                        color: "white"
                                        width: parent.width
                                        height: parent.height/2-1.5*mm
                                        anchors.bottom: parent.bottom
                                        font.pixelSize: 2.4*mm
                                        minimumPixelSize: 1*mm
                                        fontSizeMode: Text.Fit
                                        horizontalAlignment: Text.AlignHCenter
                                        wrapMode: Text.Wrap
                                        text: what
                                }
                        }
                }

// On the console I get the following message:
qml: Current Index: 0
qml: Current Index: 19

But Who change the current index to 19 ??

Thanks,
Gianluca.


_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to