GridLayout in another GridLayout



  • I have this code:
    @
    import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Window 2.0
    import QtQuick.Layouts 1.0

    Window {
    title: qsTr("СЦМ Концепт")
    color: "blue"
    width: 1920
    height: 1080

    GridLayout {
        id: grid_layout1
        anchors.fill: parent
    
            GridLayout {
                id: grid1
                Layout.fillHeight: true
                Layout.fillWidth: true
                width: 2
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "red"
                }
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "green"
                }
            }
    
            GridLayout {
                id: grid2
                Layout.fillHeight: true
                Layout.fillWidth: true
                width: 1
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "red"
                }
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "green"
                }
            }
    }
    

    }
    @

    And I get this picture:
    http://imgur.com/nq6jbH6

    But if I write this:
    @
    import QtQuick 2.0
    import QtQuick.Controls 1.0
    import QtQuick.Window 2.0
    import QtQuick.Layouts 1.0

    Window {
    title: qsTr("СЦМ Концепт")
    color: "blue"
    width: 1920
    height: 1080

    GridLayout {
        id: grid_layout1
        anchors.fill: parent
    
        Item {
            Layout.fillHeight: true
            Layout.fillWidth: true
            width: 2
    
            GridLayout {
                id: grid1
                anchors.fill: parent
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "red"
                }
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "green"
                }
            }
        }
    
        Item {
            Layout.fillHeight: true
            Layout.fillWidth: true
            width: 1
    
            GridLayout {
                id: grid2
                anchors.fill: parent
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "red"
                }
    
                Rectangle {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    color: "green"
                }
            }
        }
    }
    

    }
    @

    I get right resulte:
    http://imgur.com/lWNNOtx

    Is this a bug or maybe I do something wrong? Why I should place second GridLayout inside a Item?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.