QListWidget empty space problem
-
I use a QlistWidget to show options in a program, like below:
However the extra white space at the bottom is ugly to say the least. In theory, a statement such as
widget->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
should minimise the size of the widget. In this case it does not.Any suggestions?
Kind regards,
willem -
I believe you need to place your widgets in the layout for that to take effect. https://doc.qt.io/qt-5/layout.html
-
@willemf said in QListWidget empty space problem:
But the setSizePolicy() instruction should do it and it does not. Why?
That is the $64k question in Qt widgets layout --- let me know if you ever figure how it works! ;-)
If you do not get a better answer, there is a very old post here, https://forum.qt.io/topic/40717/set-size-of-the-qlistview-to-fit-to-it-s-content/6, which shows user doing it by calculating. Code is against the old
ListView
, but may work/be adaptable for your purpose?