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. Scrollbar width is excluded from QListView while preparing grid layout.
Forum Updated to NodeBB v4.3 + New Features

Scrollbar width is excluded from QListView while preparing grid layout.

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlistview
1 Posts 1 Posters 452 Views 1 Watching
  • 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 Offline
    D Offline
    dlmv
    wrote on 8 Sept 2019, 11:31 last edited by dlmv 9 Oct 2019, 06:28
    #1

    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
    0

    1/1

    8 Sept 2019, 11:31

    • Login

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