Important: Please read the Qt Code of Conduct -

QListWidget never minimum size

  • I'm trying to use a QListWidget with a list that can have as few as one or two items. I would like the list to be as small as the items it contains, but no matter what I try the minimum obtainable size is always 78x52 (as reported by viewportSizeHint) which is enough vertical space for about 5 or 6 items.

    Also, if I let it, the QListWidget tries to push itself even lager with a minimum vertical space for about 15 items. Where is this minimum coming from? It seems the only way to get the control smaller is by using a fixed size policy, and then setting the size manually (which I don't want to have to do).

    Is there a way to get a QListWidget to resize down to a size of one item?


  • listWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);

Log in to reply