Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QListWidget blank area at bottom (items not filling all space)
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maisoui
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • M maisoui

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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...?

      1 Reply Last reply
      2
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved