Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Row and RowLayout?

Tags:

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"
        }
    }
}
like image 525
Patric Avatar asked Apr 07 '15 02:04

Patric


1 Answers

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"
    }
}
like image 110
Meefte Avatar answered Sep 21 '22 18:09

Meefte