【问题标题】:What is the difference between Row and RowLayout?Row 和 RowLayout 有什么区别?
【发布时间】:2015-06-11 12:59:15
【问题描述】:

这与Row 的预期相同,但不适用于RowLayout。为什么?两者有什么区别?

ApplicationWindow {    
    title: "Testing"
    width: 640
    height: 480

    //RowLayout {
    Row {        
        anchors.fill: parent

        Rectangle {
            id: rect1
            width: parent.width * 0.3
            height: parent.height
            color: "blue"
        }
        Rectangle {
            height: parent.height
            width: parent.width * 0.7
            color: "red"
        }
    }
}

【问题讨论】:

  • 您有更多使用RowLayout 的选项,例如对齐。但最好使用Row,因为性能。
  • QML Row vs. RowLayout的可能重复

标签: qt qml qtquick2


【解决方案1】:

RowItem Positioner。定位器项是容器项,用于管理声明性用户界面中项的位置。

RowLayoutQt Quick Layouts 的一部分。它们在声明性用户界面上管理项目的位置和大小,非常适合可调整大小的用户界面。

RowLayout 的代码应如下所示:

RowLayout{
    anchors.fill: parent
    spacing: 0
    Rectangle{
        Layout.fillHeight: true
        Layout.preferredWidth: parent.width * 0.3
        color: "blue"
    }
    Rectangle{
        Layout.fillHeight: true
        Layout.fillWidth: true
        color: "red"
    }
}

【讨论】:

  • 作为对 Meefte 的补充回答。行是Item Positioners,行布局是Qt Quick Layouts。它们的行为方式相似,但有两个区别: - 物品定位器本身也是容器。 - Qt Quick Layouts 可以调整其项目的大小。
  • 虽然这是唯一的答案,但我认为这不是一个有用的答案。它只是复制文档,可以说没有任何作用来揭开差异的神秘面纱,因此提出了这个问题。 Row 是一个“物品定位器”。所以呢? RowLayout 是 QT 快速布局的一部分。好吧,Row 也是 QTQuick 的一部分。概念和使用上的实际和基本区别是什么?!?!
猜你喜欢
  • 2022-07-05
  • 2010-10-02
  • 2011-12-12
  • 2010-09-16
  • 2012-03-14
  • 2012-02-06
  • 2011-02-25
  • 2011-11-22
  • 2015-03-26
相关资源
最近更新 更多