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

时间:2016-03-25 16:50:00

标签: qml

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

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 个答案:

答案 0 :(得分:1)

您可以使用附加的媒体资源Layout.rowSpanLayout.columnSpan 有关详细信息,请参阅herehere 另外,使用Layout.rowLayout.column指定要放置项目的单元格 有关布局实际工作方式的详细信息,请参阅here

相关问题