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. QGridLayout with cells of constant size
Qt 6.11 is out! See what's new in the release blog

QGridLayout with cells of constant size

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.0k 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.
  • F Offline
    F Offline
    fthe
    wrote on last edited by
    #1

    Hello there,

    Say I have a QGridLayout with a custom QWidget in each cell. The QGridLayout can be modified by buttons, adding or removing cells in a fixed pattern (1x1, 2x1, 2x1 and 1x2 underneath, 2x2 etc.). The custom QWidget has a QLabel in it, showing a QString that can change during runtime.

    Now, what I would like to have is a semi-fixed size QGridLayout. "Semi-fixed" because I'd like it to adapt to the window size, but the relative sizes of the cells should remain be fixed, taking up an equal amount of space each.

    I more or less succeeded in doing it. I have a Layout manager in my Main Window communicating the window size to the QGridLayout, and I can modify my QGridLayout. The problem is that the variable size String changes the size of the custom QWidget, which communicates the size change to the QGridLayout (I assume...?), which gives it more space. Something... IT SHOULD JUST NOT DO. I want the size of the cells to be constant.

    I've been fighting with this thing for a while now, so ... dear forum, can you help?

    Thanks alot in advance!

    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