Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dynamic Gridview Cellwidth and CellHeight
Forum Updated to NodeBB v4.3 + New Features

Dynamic Gridview Cellwidth and CellHeight

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 235 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.
  • admiral142A Offline
    admiral142A Offline
    admiral142
    wrote on last edited by
    #1

    I'm using a GridView to display some rectangles. In the event that the number of icons I have is odd, I want to stretch the rectangles in the bottom row to fill that bottom row. I've been able to set the rectangles correctly, but the GridView cellWidth is proving difficult to change. Is there a way to set the GridView cellWidth differently based on the row that you're on? Something like:

    
    GridView{
            model: menuList
            delegate: menuItemDelegate
            cellHeight: parent.height / rows
            cellWidth: {
                //bottomColsFill is TRUE when there is an odd number of items in the menuList
                if(bottomColsFill && index > (menuList.length - cols)){
                    return parent.width / (cols - 1);
                }
                else{
                    parent.width / cols;
                }
            }// previous code parent.width / cols
        }
    
    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