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



  • 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



  • 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
    }
    

    }
    @



  • 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

    }

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.