Skip to content

qt: introduce WinUI 3 style custom scroll bar

Fatih Uzunoğlu requested to merge fuzun/vlc:qt/winui3scrollbar into master

This is essentially a revival of this very old merge request: !1211 (closed).

This is not much different than Qt Quick Basic scroll bar, as it is already similar to the WinUI 3 style, but offers some advantages such as being able to see where the view content is positioned without hovering the scroll bar.

Why we need this:

  • We customize the rest of the controls, the scroll bar looks alien if it is not customized (such as the KDE Breeze scroll bar).
  • Qt Quick Basic (Windows) scroll bar is too basic and gets hidden completely unless the scroll bar is active.
  • Scroll bar is not scaled according to the interface scale.
  • Scroll bar does not use the theme palette for colorization.
  • #26135 (closed)

I followed the WinUI 3 design:

  • Always on is respected, the background disappears and the handle becomes tinier, but it is always shown.
  • When hovered, the background is shown and the handle becomes larger with a transition.
  • Colors do not change on hovered/pressed state.
  • When scrolling with wheel, the background is not shown and the handle does not get larger.

Unfortunately, up and down arrow buttons are not possible to do without having access to the private headers (as Qt Quick Templates QQuickScrollBar don't provide this functionality, we need to subclass), so that is postponed for now.

Disabling free adjustment (clicking an arbitrary position in scroll bar background and the handle moves there), instead of page scroll as Windows does is also problematic without having access to the private headers, this is either postponed or won't be fixed (I'm not sure if we want this behavior).

Default policy is left ScrollBar.AsNeeded, I have not changed this. Note that this is only relevant when the view content is larger than the viewport. There is no reason to display the scroll bar if scrolling is not feasible (this is not about #26135 (closed), which is about showing the scroll bar when scrolling is feasible).

I have recorded this video:

newscrollbar-2025-03-21_17.25.57

Close #26135 (closed).

Request review @chub.

Merge request reports

Loading