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. Grid behavior when there are too many items?
Forum Updated to NodeBB v4.3 + New Features

Grid behavior when there are too many items?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.1k 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.
  • R Offline
    R Offline
    Rolias
    wrote on last edited by
    #1

    EDIT
    I would delete this post if I could. Turns out my regular rectangle test was flawed. Both tests behave the same. The extra items just sort of "wrap around" so the 10th item just gets put over the 9th item.


    I'm just trying to fully understand the Grid positioner. The docs explain that when you set the number of rows and don't have enough items you'll get zero width items. It's strangely silent on what happens when you have too many. As a test I created 10 rectangles and put them in a 3x3 grid (purposely creating more items than the grid can hold) and the first nine showed up. Fine, it looked at first like the extra items just aren't shown. Then I tried a similar testing using a repeater with images and left one of the rectangles in the grid.
    @ Grid{
    columns: 3
    rows : 3

            Repeater{
                model : 9
    
                Image{
                    source :"balloon.jpg"
                    width : 50
                    height : 50
                }
            }
    
            Rect50{
                color : "darkviolet"
            }
        }@
    

    To my surprise, I have eight visible balloon images. The first cell of the grid has my last rectangle. Is having more items than a grid can hold simply undefined behavior or is this a bug?

    !https://dl.dropboxusercontent.com/u/41770120/Grid.jpg(Image of grid)!

    Check out my third course in the trilogy on Qt
    "Integrating Qt Quick with C++"
    http://bit.ly/qtquickcpp
    published by Pluralsight

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

      you have only 3 rows and 3 columns. You have 10 elements to display. Increase the number of rows or columns or reduce the items to 9. It may solve your problem. I will try this shortly.

      Try this
      @Rectangle {
      height: 400
      width: 400

      Grid{
          anchors.fill: parent
          columns: 3
          rows : 4
          spacing: 2
      
          Repeater{
              model : 9
              Rectangle{
                  //source :"balloon.jpg"
                  width : 50
                  height : 50
                  color : "red"
              }
          }
          Rectangle{
              height: 50;width: 50
              color : "blue"
          }
      }
      

      }
      @

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

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rolias
        wrote on last edited by
        #3

        You seem to have missed the point. I edited the question to try to make what I'm asking even clearer.

        Check out my third course in the trilogy on Qt
        "Integrating Qt Quick with C++"
        http://bit.ly/qtquickcpp
        published by Pluralsight

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

          This looks like a bug to me. If there are more items, it should clip the last item. It is odd that it starts putting the items at the top corner again.

          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