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. Gridlayout resize automatically
Forum Updated to NodeBB v4.3 + New Features

Gridlayout resize automatically

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.8k 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.
  • J Offline
    J Offline
    Jc_Opc
    wrote on last edited by
    #1

    Hi all,

    This maybe a quick question, I created a widget with designer, that widget has a gridlayout which can accept 4 widgets (2x2 matrix). The widgets are inserted dynamically, at the beginning is only 1 then 2,3 and the last is 4. When all of them are in the girdlayout matrix, their size are ok, but when there is only one it looks big.
    Is there a way to:

    1. Keep their size the same all the time in the gridlayout.
    2. when the first is added, I would to be displayed it a the center of the gridlayout.

    Thanks

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      If your add these widgets by

      layout->addWidget(widget, row, column, Qt::AlignCenter);
      

      Then Qt will try to keep their size as their sizeHint() and make them at the center of their cells.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved