Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

As for QML in the ListView to do the centering in the center?



  • Good afternoon.
    Turned ListView to horizontal position.
    As I scroll, the items line up at the left edge of the window.
    As for QML in the ListView to do the centering in the center?
    Or maybe how to disable auto-scrolling?



  • @Mikeeeeee hi
    can you explain your problem better ? what is QMK ? you can past you code here..



  • Sorry, QML
    I need to the items in the ListView were front and center rectangleForListView , not his left? Or do I need to disable the align on the left edge rectangleForListView.

        Rectangle{
        //Flickable {
            //contentX: 100
            id: rectangleForListView
            y: parent.height * 0.15
            height: parent.height * 0.7
            anchors.left: parent.left
            //anchors.leftMargin: parent.width * 0.10
            anchors.right: parent.right
    
            ListView
            {
                id: myListView1
                highlightRangeMode: ListView.StrictlyEnforceRange
                anchors.fill: parent
                orientation : ListView.Horizontal
                snapMode: ListView.NoSnap
                //spacing: myListView1.width * 0.06
                contentX: 100
                contentWidth: 100
    
                delegate:
                    Item
                {
                    id: itemDelegate
                    width : myListView1.width < myListView1.height ? myListView1.width * 0.7 : myListView1.height * 1
                    height: myListView1.width < myListView1.height ? myListView1.width * 1 : myListView1.height * 0.7
                    //height: myListView1.height * 1
                    //width: myListView1.width * 0.7
    
                    Rectangle
                    {
                        anchors.fill: parent
                        anchors.leftMargin: myListView1.width * 0.06
    
                        Rectangle{
                            id: rectangleNameSite
                            anchors.left: parent.left
                            anchors.right: parent.right
                            anchors.top: parent.top
                            height: parent.height * 0.05
                            color: "grey"
    
                            Text{
                                id: indexPage
                                x: parent.width * 0.05
                                //y: parent.height * 0.05
                                //anchors.horizontalCenter: parent.horizontalCenter
                                anchors.verticalCenter: parent.verticalCenter
                                horizontalAlignment: Text.AlignHCenter
                                font.pointSize: parent.height * 0.6
                                text: textForIndexPage//qsTr("textDriver")
                                color: "white"
                            }
                        }
    
                        Rectangle{
                            id: rectangleForSite
                            color: "red"
                            anchors.left: parent.left
                            anchors.right: parent.right
                            anchors.bottom: parent.bottom
                            anchors.top: rectangleNameSite.bottom
    
                        }
    
                        Rectangle{
                            anchors.left: parent.left
                            anchors.right: parent.right
                            anchors.bottom: parent.bottom
                            height: parent.height * 0.09
                            color: "#82707099"
    
                            Image {
                                id: myImage
                                source: "qrc:/icons/close.png"
                                anchors.horizontalCenter: parent.horizontalCenter
                                anchors.verticalCenter: parent.verticalCenter
                                height: parent.height * 1
                                width: height
                            }
                            /*MouseArea{  //delete ellement
                                id: closeTabInListView
                                anchors.fill: parent
    
                                onClicked: {
                                    console.log("Index: " + index)
                                    myListModel1.remove(index)
                                }
                            }*/
                        }
                    }
                }
    
                model: ListModel
                {
                    id: myListModel1
                }
            }
        }
    


  • @Mikeeeeee maybe swipeview is what you need ?



  • No, the SwipeView will not show the elements when the elements are partially hidden from view.



  • highlightRangeMode: ListView.ApplyRange


Log in to reply