Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Scrollbar Quirks
Forum Updated to NodeBB v4.3 + New Features

Scrollbar Quirks

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 204 Views 2 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.
  • P Offline
    P Offline
    preiter
    wrote on last edited by
    #1

    I'm using QML with Qt6.6. I am using the Fusion Style and I have implemented themes by overriding the system palette.

    I'm running into an issue with Scrollbar. I have some users that see the slider in a dark gray color and some users see it as white (which is invisible against the background).

    I have worked around this issue by creating a custom component like this:

    ScrollBar {
    // Customize the slider (contentItem)
    contentItem: Rectangle {
    implicitHeight: orientation == Qt.Horizontal ? 6 : null
    implicitWidth: orientation == Qt.Vertical ? 6 : null
    radius: 3

        opacity: .5
        color: palette.buttonText
    }
    

    }

    But I'm still confused about why this is happening. I have not found any color in the palette which will affect the color of the scrollbar slider and I do not understand why different users would get a different color.

    While I am asking about scrollbars... the default scrollbar policy "AsNeeded" has the behavior that the scrollbar only shows up when there is enough content to scroll (which I want), but it also has the behavior that the scrollbar only appears when moused over (which I do not want). I have worked around the issue like this:

            policy: dataViewerListView.contentWidth > dataViewerListView.width ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
    

    I would like to capture this in a custom component, but this implementation requires referencing properties which are specific to each usage. Is there any way to make it more generic?

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      Qt populates palettes from different sources, depending on which platform your users are on.
      KDE has its own platform theme. Gnome desktops with GTK installed read it from the GTK theme.
      Maybe implement categorized logging in your app and log the scrollbar's palette. The return value of QGuiApplication::platformName() could also be helpful information. Then your users can send you the results for analysis.

      A QScrollBar in QFusionStyle uses the following colors:

      • Groove: QPalette::Window
      • Handle (draggable part): QPalette::Mid
      • Arrows: QPalette::ButtonText / QPalette::Button (background)
      • Background: QPalette::Base

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      1
      • P Offline
        P Offline
        preiter
        wrote on last edited by
        #3

        Thank you so much, Mid does indeed change the color of the handle, but another color seems to control the color of the handle while it is being dragged. I will figure it out.

        One more question. Is this documented anywhere? Or is the source code available? I searched everywhere I could think of and could not locate it. I found this page: https://doc.qt.io/qt-6/qtquickcontrols-fusion.html which only covers a subset of the palette usage.

        1 Reply Last reply
        0
        • P preiter has marked this topic as solved on

        • Login

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