Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Problem with GridView

    QML and Qt Quick
    1
    2
    83
    Loading More Posts
    • 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
      RobM last edited by

      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 Reply Quote 0
      • R
        RobM @RobM last edited by

        @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 Reply Quote 0
        • R
          RobM @RobM last edited by

          @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 Reply Quote 0
          • First post
            Last post