Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
The height of QListWidget is not consistent with the count of items
RogerCui last edited by
Please refer to the picture "A Plastique style list widget" in "http://doc.trolltech.com/4.7/qlistwidget.html"
I only have two or three items, but the height of list widget is much more than needed.
How can I control that? Thanks!
Franzk last edited by
Resize it. The QListWidget does not size itself to the amount of items in it. It would be silly to do so in most cases. It's basically a QScrollArea, which means that if the contents are small, nothing happens, but if the contents are larger than can be displayed, a scrollbar appears.
Also note that the required size may be subject to the style used to draw the widget. Items may differ several pixels in size between styles.
baysmith last edited by
Sum the sizes of all items with "visualItemRect()":http://doc.trolltech.com/4.7/qlistwidget.html#visualItemRect and use the result to set the QListWidget to a fixed size.