I'm using QListWidget
with setItemWidget
and when adding items to the list and scrolling down to the bottom I get this result:
So there's an area which is completely blank at the bottom (not selectable, in the image above the last item in the list has been selected)
How can I get rid of this blank area at the bottom of the list?
Please note that the height of the rows can be different within a list
Grateful for help and with kind regards, Tord
It's possible to change the type of vertical scrolling that is done for list by using setVerticalScrollMode
for the QListWidget
so that the scrolling is done per pixel (instead of per item which is the default):
self.list_widget.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
The result is that rows that are in the top-most part of the QListWidget box can be drawn only in part, which in turn means that the blank area that exists when scrolling per item will disappear:
Reference documentation: https://doc.qt.io/qt-5/qabstractitemview.html#verticalScrollMode-prop
I'm using exactly the same approach and I get rid of the blank area by creating a widget that contains my QListWidget
and use :
listwidget.setFixedSize(widget.width(), listwidget.sizeHintForRow(0) * listwidget.count() + 2 * listwidget.frameWidth())
listwidget
is you QListWidget
object
widget
is the widget that contains your QListWidget
object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With