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. Problem with GridView
Forum Update on Monday, May 27th 2025

Problem with GridView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 235 Views
  • 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
    RobM
    wrote on 1 Aug 2020, 22:32 last edited by
    #1

    I am trying to display a list of images, and strings which I have setup in the C++ in this GridView, but for some reason, it isn't working. I know the list is populated because I can display both images in this manner:

          Row
          {
            spacing: 5
    
            IconButton
            {
              id: cardOne
              rounded: false
              imageSource: mod_data.optionsListImages[0]
              text: mod_data.optionsList[0]
            }
    
            IconButton
            {
              id: cardTwo
              rounded: false
              imageSource: mod_data.optionsListImages[1]
              text: mod_data.optionsList[1]
            }
          }
    

    However, when I use GridView or ListView to try and display them only one image shows up:

        Item
        {
          id: sectionGridViewContainer
    
          GridView
          {
            id: sectionGridView
    
            anchors.fill: parent
            cellHeight: 282
            cellWidth: parent.width/3
            
            model: mod_data.optionsListImages
    
            delegate: IconButton
            {
              id: delegateThing
              rounded: false
              imageSource: modelData
            }
          }
        }
    

    Any idea what I am doing wrong? Could this be a bug?

    R 1 Reply Last reply 2 Aug 2020, 01:38
    0
    • R RobM
      1 Aug 2020, 22:32

      I am trying to display a list of images, and strings which I have setup in the C++ in this GridView, but for some reason, it isn't working. I know the list is populated because I can display both images in this manner:

            Row
            {
              spacing: 5
      
              IconButton
              {
                id: cardOne
                rounded: false
                imageSource: mod_data.optionsListImages[0]
                text: mod_data.optionsList[0]
              }
      
              IconButton
              {
                id: cardTwo
                rounded: false
                imageSource: mod_data.optionsListImages[1]
                text: mod_data.optionsList[1]
              }
            }
      

      However, when I use GridView or ListView to try and display them only one image shows up:

          Item
          {
            id: sectionGridViewContainer
      
            GridView
            {
              id: sectionGridView
      
              anchors.fill: parent
              cellHeight: 282
              cellWidth: parent.width/3
              
              model: mod_data.optionsListImages
      
              delegate: IconButton
              {
                id: delegateThing
                rounded: false
                imageSource: modelData
              }
            }
          }
      

      Any idea what I am doing wrong? Could this be a bug?

      R Offline
      R Offline
      RobM
      wrote on 2 Aug 2020, 01:38 last edited by
      #2

      @RobM Ah I figured it out. It would seem that Row is somehow capable of setting it's parent elements width while GridView and ListView are not. So, I had to set the parent elements width first, then bind the GridView correctly for everything to display.

      1 Reply Last reply
      0

      1/2

      1 Aug 2020, 22:32

      • Login

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