【问题标题】:Move GridLayout rows to top将 GridLayout 行移到顶部
【发布时间】:2021-05-06 08:02:05
【问题描述】:

我有一个 GridLayout,当没有足够的项目来填充可用空间时,行似乎均匀分布以填充垂直空间。但我希望将行强制到 GridLayout 的顶部。

如果我移除下部锚点并设置 Layout.maximumHeight,那么我的容器会缩小,因此项目会出现在顶部,但我不确定这是正确的方法。

【问题讨论】:

    标签: qml row grid-layout


    【解决方案1】:

    将 GridLayout 放入带有展开的 Item 的 ColumnLayout 中。例如

    ColumnLayout {
        // anchors or Layout settings to size it.
    
        GridLayout {
            // Let it size itself vertically implicitly.
        }
    
        Item {
            // Use this to fill the space below it.
            Layout.fillHeight: true
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-01
      • 2013-12-08
      • 2014-09-04
      • 2020-03-20
      相关资源
      最近更新 更多