美文网首页
【QML】Row与RowLayout的区别

【QML】Row与RowLayout的区别

作者: 4thirteen2one | 来源:发表于2019-04-26 18:33 被阅读0次

https://stackoverflow.com/questions/29482970/what-is-the-difference-between-row-and-rowlayout
https://stackoverflow.com/questions/16914785/qml-row-vs-rowlayout
https://doc.qt.io/qt-5/qtquick-usecase-layouts.html

  • 使用Row
    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
    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"
        }
    }
    

相关文章

网友评论

      本文标题:【QML】Row与RowLayout的区别

      本文链接:https://www.haomeiwen.com/subject/vkwqnqtx.html