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. Trouble with GridView
Forum Updated to NodeBB v4.3 + New Features

Trouble with GridView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 202 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    I have a rather simple GridView who's model is a list of url's for images. The delegate is Image and I am not specifying anything about the image other than it's source and id:

    Component
    {
      id: theComponent
      Item
      {
        id: theItem
        GridView
        {
          id: theGridView
          model: modelData.optionsListImages
          anchors.fill: parent
          anchors.margins: 10
          delegate: Image
          {
            id: theImage
            source: modelData
          }
        }
      }
    }
    

    the problem I am having is that these images overlap one another. That is, until I start messing around with the cellWidth property... until I specify that the property should be the width of the image, but I can't specify that width like this:

    cellWidth: theImage.width
    

    Instead I have to specify the actual images size, like so:

    cellWidth: 250
    

    I was under the impression that it would automatically set the cellWidth and cellHeight property's to be the size of whatever is inside the delegate? That's what the examples here seem to suggjest. I would rather have the cell width/height grow/shrink depending on the size of the image. Perhaps I cant? Perhaps I actually need to MAKE SURE my images are all EXACTLY the same size and specify it directly?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Circuits
      wrote on last edited by
      #2

      Apparently I was wrong: "The item size of the GridView is determined by cellHeight and cellWidth. It will not resize the items based on the size of the root item in the delegate." So I suppose you do have to explicitly set your cellWidth and cellHeight to be that of the root item in the delegate.

      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