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

Problem with GridView



  • 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?



  • @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.



  • @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.


Log in to reply