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. GridView - Arrangement of Elements
QtWS25 Last Chance

GridView - Arrangement of Elements

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.8k 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.
  • G Offline
    G Offline
    goli
    wrote on last edited by
    #1

    I need to create a GridView , with 2 rows and 4 columns. I want to insert the elements into the grid row after row, and also to enable scrolling of the grid from left to right.
    This is what I tried:
    @
    GridView
    {
    id: myGrid

            width: 800
            height: 400
    
            anchors.centerIn: parent
    
            model: .....
            delegate: .....
            cellWidth: 200
            cellHeight:200
    
            flow: GridView.TopToBottom
            highlightFollowsCurrentItem: true
            preferredHighlightBegin: 0
            preferredHighlightEnd: cellWidth
            highlightRangeMode : GridView.StrictlyEnforceRange
            interactive: (count > 8)
        }
    

    @

    This code allows scrolling horizontaly, and don't allows arrangement of the elements row after row , but column after column.

    any idea?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dajansen
      wrote on last edited by
      #2

      You're basically after the unconsidered "lay out from left to right, but also scroll that way".
      What you might have to do is place the GridView on a Flickable.

      @Item {
      id: something
      height: 400
      width: 400

      Flickable {
        anchors.fill: parent
        contentHeight: myGrid.height
        contentWidth: myGrid.width
        GridView {
            id: myGrid
            width: 200 * Math.ceil(count/2)
            height: 400
      
            model: 8
            delegate: Rectangle { height: 200; width: 200; border.color: "black"
                Text { anchors.centerIn: parent; text: model.index }
            }
            cellWidth: 200
            cellHeight:200
            interactive: false
        }
      }
      

      }@

      QtQuick Quality Engineer / Lab Monkey
      Nokia Brisbane

      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