首页 文章

如何使用QML在GridLayout中占用多个列或行?

提问于
浏览
1

我想知道如何在GridLayout.follow中占用多个列或行是我的代码 .

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1

Rectangle {
        width: 320
        height: 250

        GridLayout {
            anchors.left: parent.left
            anchors.bottom: parent.bottom

            rows: 2
            columns: 3

            Button{
                    text: "one"
                }

            Button{
                    text: "two"
                }

            Button{
                    text: "three"
                }

            Button{
                    text: "four"
                }

            Button{
                    text: "five"
                }
                Layout.columnSpan: 2

            }
    }

我想如何使“五”按钮占据两列 . 谢谢 !

1 回答

  • 1

    您可以使用附加属性 Layout.rowSpanLayout.columnSpan .
    有关详细信息,请参阅herehere .
    此外,使用 Layout.rowLayout.column 指定应放置项目的单元格 .
    有关布局实际工作方式的更多详细信息,请参见here .

相关问题