Gridlayout resize automatically
Solved
General and Desktop
-
wrote on 10 Sept 2020, 16:35 last edited by
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:- Keep their size the same all the time in the gridlayout.
- when the first is added, I would to be displayed it a the center of the gridlayout.
Thanks
-
wrote on 10 Sept 2020, 18:09 last edited by Bonnie 9 Oct 2020, 18:10
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.
2/2