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. Inconsistent look of QScrollBar on Windows
Qt 6.11 is out! See what's new in the release blog

Inconsistent look of QScrollBar on Windows

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 447 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.
  • T Offline
    T Offline
    Thinium
    wrote on last edited by Thinium
    #1

    I have a custom scroller which looks fine on Mac, but on Windows it has a strange gray background.

    Here is a photo of the custom vertical scroller. The horizontal scroller is the default scroller, just for comparison:
    capture-scroller.png

    Here is how it looks on Mac:
    Screen Shot 2020-07-24 at 17.28.13.png
    Here is my code for the custom scroller. Am I missing something in my stylesheet?

    // in the MainWindow:
    setStyleSheet( "QScrollBar:vertical { \
                      background:rgb(42, 42, 42); \
                      border-top-right-radius:2px; \
                      border-bottom-right-radius:2px; \
                      width:16px;\
                      margin:0px;\
                      }\
                      QScrollBar::handle:vertical { \
                      background-color:rgb(66, 66, 66); \
                      border-radius:4px; \
                      min-height:20px; \
                      margin:2px 4px 2px 4px;\
                      }\
                      QScrollBar::handle:vertical:hover, QScrollBar::handle:horizontal:hover{ \
                      background-color:rgb(42, 130, 218);\
                      }\
                      QScrollBar::add-line:vertical{ \
                      background:none;\
                      height:0px;\
                      subcontrol-position:right;\
                      subcontrol-origin:margin;\
                      }\
                      QScrollBar::sub-line:vertical {\
                      background:none;\
                      height:0px;\
                      subcontrol-position:left;\
                      subcontrol-origin:margin;\
                      }\
                      QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {\
                          border: 2px solid grey;\
                          width: 3px;\
                          height: 3px;\
                          background: white;\
                      });
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      Thinium
      wrote on last edited by
      #2

      Turns out that I needed to add also the arrow and page definition on Windows. For example:

      QScrollBar:left-arrow:vertical, QScrollBar::right-arrow:vertical {
      border: 2px solid grey;
      width: 3px;
      height: 3px;
      background: white;
      }

      QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
      background: none;
      }
      This fixed my original issue, but the arrows aren't visible (which doesn't matter in my case, but it's just weird that they don't show up).

      1 Reply Last reply
      1

      • Login

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