What is the difference between Row and RowLayout?

15,236

Row is a Item Positioner. Positioner items are container items that manage the positions of items in a declarative user interface.

RowLayout is part of Qt Quick Layouts. They manage both the positions and the sizes of items on a declarative user interface, and are well suited for resizable user interfaces.

Your code with RowLayout should look like this:

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"
    }
}
Share:
15,236
Patric
Author by

Patric

Updated on June 19, 2022

Comments

  • Patric
    Patric about 2 years

    This works as intended with Row, but not with RowLayout. Why? What is the difference between the two?

    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"
            }
        }
    }