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. How to make cells of a grid all the same size in QML?
Forum Updated to NodeBB v4.3 + New Features

How to make cells of a grid all the same size in QML?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.9k 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
    mshefiti
    wrote on last edited by
    #1

    Hi everyone,

    I have been working on a UI where everything is responsive. I have a grid filled with elements.
    Even though all the elements have the same size specifications, the grid sometimes is longer on one side than the other, like in the image:
    https://drive.google.com/file/d/0ByMArgb35-ebRlZYM3cyWHFNWjg/view?usp=sharing

    Does anyone know how to force it to balance equally on both sides?

    Thanksss

    1 Reply Last reply
    0
    • shavS Offline
      shavS Offline
      shav
      wrote on last edited by
      #2

      Hi,

      Could you share code of grid?

      In my project I'm using code:
      @
      GridView {
      id: classesListGrid
      anchors.horizontalCenter: parent.horizontalCenter
      width: parent.width
      height: parent.height
      cellHeight: 45
      cellWidth: classesListGrid.width / 3
      clip: true
      model: someModel
      delegate: Item {
      width: classesListGrid.cellWidth
      height: classesListGrid.cellHeight

          //Content od every item of grid
      }
      

      }
      @

      Mac OS and iOS Developer

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

        Hi shav, this is my code, it does not accept cellHeight property :/

        @GridLayout{
        id: controlsGridPlaceholder
        objectName: "controlsGridPlaceholder"
        anchors.top: parent.top
        Layout.fillHeight: true
        Layout.fillWidth: true
        columns: (screenOrientation === 2 || screenOrientation === 8) ? 1 : 2

        }

        @

        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