Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. As for QML in the ListView to do the centering in the center?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by Mikeeeeee
    #1

    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?

    ODБOïO 1 Reply Last reply
    1
    • M Mikeeeeee

      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?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        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
                    }
                }
            }
        
        ODБOïO 1 Reply Last reply
        0
        • M Mikeeeeee

          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
                      }
                  }
              }
          
          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @Mikeeeeee maybe swipeview is what you need ?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #6

              highlightRangeMode: ListView.ApplyRange

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved