Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QListWidget blank area at bottom (items not filling all space)



  • Hi,

    I'm using a QListWidget (v. 5.10.1) and I have a strange blank area at bottom, and items are not well laid out. I'm using IconMode with a TopToBottom flow. Fist, I thought this blank area comes from scroll bar, so I disabled it and I set height and margin to 0 in style sheet but no success. On this 2 pictures you can see the blank area (items are red square):
    0_1535700779057_qlistwidget_bottomspacing1.png
    0_1535700791487_qlistwidget_bottomspacing2.png

    On the second picture, we can see that there is enough space to display on more row of items at bottom.
    How to get rid of the blank area ?

    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    setIconSize(QSize(22, 22));
    setMovement(QListView::Static);
    setFlow(QListView::TopToBottom);
    setViewMode(QListView::IconMode);
    setSpacing(2);
    setResizeMode(QListView::Adjust);
    setSizeAdjustPolicy(QListWidget::AdjustToContents);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    
    QListWidgetItem::sizeHint returns myListWidget->iconSize();
    

    Any suggestions are welcome.
    Best regards,
    Jonathan



  • @maisoui
    Assuming you really do have enough room (I don't know, if it were me I'd try increasing the vertical size available first just to make sure), I don't know but if you can't get it working it might be the case that you need to heed https://stackoverflow.com/questions/24529062/qt-5-3-qlistview-column-problems where they claim you need to use QTableView or QColumnView instead...?


  • Qt Champions 2019

    I'm not aware of a qt bugtracker entry for this specific issue - therefore can you please provide a small, compilable example so we can take a look on what's going wrong? thx.


Log in to reply