Rando Hinn
Rando Hinn

Reputation: 1322

QML grid specify position manually

Can I set the column and row of QML Grid children elements manually? In this case, I'd like the Button to be in row 11 column 1.

 Grid {
        rows: 11
        columns: 4

        Button {
            height: 128
            width: 128
            text: qsTr("Sahtel lahti")
        }

    }

Upvotes: 0

Views: 1482

Answers (1)

Lasall
Lasall

Reputation: 480

As already mentioned in the comments you can use GridLayout and Layout.row and Layout.column.

import QtQuick 2.13
import QtQuick.Layouts 1.13

GridLayout {
    columns: 3

    Text { text: "4"; Layout.row: 1; Layout.column: 0}
    Text { text: "3"; Layout.row: 0; Layout.column: 2}
    Text { text: "2"; Layout.row: 0; Layout.column: 1}
    Text { text: "1"; Layout.row: 0; Layout.column: 0}
}

Upvotes: 2

Related Questions