Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Unsolved Scrollbar width is excluded from QListView while preparing grid layout.

    General and Desktop
    qlistview
    1
    1
    272
    Loading More Posts
    • 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.
    • D
      dlmv last edited by dlmv

      I have a QlistView with items of various sizes and with resizeMode=adjust. To distribute items evenly I override resizeEvent() and set the width of gridSize to be 1/n of the viewport width.
      The problem is that the viewport width seems to be not the one which is used to arrange the grid cells.

      1. When the vertical scrollbar is shown, I found from testing that the width should be decreased by 1.

      2. When the vertical scrollbar is hidden (I use ScrollBarAsNeeded setting), I need to (additionally to a "1" from previous) manually subtract its width (which is 14 in my case and can be deduced from the active style) in order to achieve a correct behavior. However, this approach always leaves an empty area at the (hidden) scrollbar position.

      I haven't found the information about the first case, but for the second one it seems that the cause is in the method of a private class:
      https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qlistview.cpp.html#_ZN16QListViewPrivate18prepareItemsLayoutEv

      I understand, that in some cases allowing the grid to occupy the scrollbar area can result in the blinking of the scrollbar, but, if I understand correctly, it is not my case. So, is there a way to distribute grid cells on a full viewport width when the vertical scrollbar is not shown?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post