Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qml gridlayout does not position last child
Forum Updated to NodeBB v4.3 + New Features

qml gridlayout does not position last child

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 742 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MajidKamali
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Karim
      wrote on last edited by
      #2

      Hi Majid,

      I'm experiencing the same annoying issue.
      Did you find a fix ?

      Thanks.

      Karim

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        @Karim, It should absolutely work without any issue. Above code works without any issue. Have you tried with simple example ? Can you paste the example code.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved