qml gridlayout does not position last child



  • Hi.
    I want to add multiple custom items to GridLayout dynamically, but last item does not position properly. It goes to point (0, 0) of GridLayout.

    GridLayout {
                id: grid
                anchors.fill: parent
                columns: 5
    
                Component.onCompleted: fillGridItems()
            }
    

    And code for fillGridItems :

    function fillGridItems() {
            var comp = Qt.createComponent("../MyItem.qml")
            var dimension = upRect.width * itemWidthPercent
    
            for(var i = 0; i < 10; i++) {
                    for(var j = 0; j < 5; j++) {
                            var obj = comp.createObject(grid, {
    //                                                column: j,
    //                                                row: i,
                                                    "Layout.alignment": Qt.AlignHCenter | Qt.AlignVCenter,
                                                    width: dimension,
                                                    height: dimension,
                                                    source: Cte.itemsSources[i],
                                                    sourceSize: Qt.size(dimension, dimension)
                                                });
                            itemsList.push(obj);
                    }
            }
    }
    

    It looks like that the last item (i ==9 && j == 4), is not child of grid layout !

    What is the problem? Is this a bug?


Log in to reply
 

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