How do you change the behavior of a QListWidget so that it changes its height instead of selecting a (apparently arbitrary) height and adding scrollbars? See screenshot:

QListView should fill as much horizontal space as possible (creating as many “columns” if you do.) Then they wrap and make as many rows as necessary to fit all the elements. These calculations should be adjusted as the window resizes. It all works fine.
However, what I want is that instead of keeping the height the same, the QListView should grow or shrink vertically and never need to scroll. Scrolling, if necessary, will be handled in the parent QWidget , which contains all the labels and lists. It seems that as soon as the height of the QListWidget (not sure where its default value QListWidget from), it never changes. In some cases, it is too large (see the second list of "Test" above) and too small in others (see the first list of "empty cards" above).
The markup above is not surprising: two QLabel and two QListWidget in a QVBoxLayout. Here are the properties that I set on QListWidget :
setMovement(QListView::Static); setResizeMode(QListView::Adjust); setViewMode(QListView::IconMode); setIconSize(QSize(128, 128));
(I already tried setting horizontal and vertical scroll policies, but that just turns off the scroll bars, cutting off the content. Not what I want.)
c ++ qt qlistview qlistwidget
Dave mateer
source share