Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Putting Repeater and standalone item in GridLayout leads to weird behavior



  • My code:

    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtQuick.Layouts 1.3
    
    Window {
        visible: true
        width: 640
        height: 480
    
        GridLayout {
            id: grid
            anchors.fill: parent
            columns: 6
            Repeater {
                model: 7
                Rectangle {
                    color: "blue"
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                }
            }
            //Rectangle {color: "red"; width: 20; height: 20}
        }
    }
    

    It shows this:

    screenshot

    Which is fine.

    But when you uncomment the line containing color: "red", the layout breaks:

    screenshot

    Any idea why that is and how to fix it?


Log in to reply