Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [QML] Wrap items inside a horizontal ListView ?
QtWS25 Last Chance

[QML] Wrap items inside a horizontal ListView ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k Views
  • 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.
  • K Offline
    K Offline
    Kaxu
    wrote on last edited by
    #1

    Hi, i have a horizontal ListView with the following code:

    Rectangle {
    
    anchors.fill: parent
    color: "red"
    radius: 100
    
          ListView {
          id: insideCircle
          model: app.exampleModel
          anchors.left: parent.left
          anchors.top: parent.top
          anchors.leftMargin: 20
          width: parent.width
          height: parent.height
          anchors.topMargin: 15
           clip: true
           spacing: 13
           orientation: ListView.Horizontal
           delegate:  Rectangle {
                   Rectangle {color: "green"; radius: 100; width: 10;height: 10}
           }
        }
    }
    

    Which gives me something like this when there is a lot of elements in the model:
    Example

    I'd like the green dots not to keep going after reaching the parent width, but instead going on the line below ( like a HTML "<br>" does ).

    Any ideas ?

    p3c0P 1 Reply Last reply
    0
    • K Kaxu

      Hi, i have a horizontal ListView with the following code:

      Rectangle {
      
      anchors.fill: parent
      color: "red"
      radius: 100
      
            ListView {
            id: insideCircle
            model: app.exampleModel
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.leftMargin: 20
            width: parent.width
            height: parent.height
            anchors.topMargin: 15
             clip: true
             spacing: 13
             orientation: ListView.Horizontal
             delegate:  Rectangle {
                     Rectangle {color: "green"; radius: 100; width: 10;height: 10}
             }
          }
      }
      

      Which gives me something like this when there is a lot of elements in the model:
      Example

      I'd like the green dots not to keep going after reaching the parent width, but instead going on the line below ( like a HTML "<br>" does ).

      Any ideas ?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Kaxu
      Wouldn't GridView be best suitable here ?

      import QtQuick 2.4
      
      Item {
          width: 200
          height: 200
          GridView {
              id: grid
              model: 30
              anchors.fill: parent
              cellWidth: 10; cellHeight: 10
              delegate:  Rectangle {
                  Rectangle {color: "green"; radius: 5; width: 10;height: 10}
              }
          }
      }
      

      157

      1 Reply Last reply
      2
      • K Offline
        K Offline
        Kaxu
        wrote on last edited by
        #3

        Thanks for the quick answer, that's exactly what I was looking for !

        p3c0P 1 Reply Last reply
        0
        • K Kaxu

          Thanks for the quick answer, that's exactly what I was looking for !

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Kaxu Glad that it helped you :) Please mark post as solved. Edit the post title and prepend [Solved].

          157

          1 Reply Last reply
          0

          • Login

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