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. Styled background color of QScrollBar is tinted white

Styled background color of QScrollBar is tinted white

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

    With Qt 6.4.2, Windows 10, and a stylesheet applied to QScrollBar, I'm having trouble setting the background color of the scroll bar. Whatever color I set always seems to have a white tint applied to it.

    For example, when I set the background color to black, the actual color is a light gray:

    enter image description here

    When I set it to red, the actual color is a light pink.

    Furthermore, I noticed that when I take a screenshot, the color in the screenshot is sometimes correct and doesn't match what I actually saw on the screen. I have no idea why, and it makes it hard to share good screenshots in this post (screenshots of my red one show actual pure red even though it's light pink on the screen).

    What is going on?

    Here is my full stylesheet (which is being set on qApp), just in case it's a matter of something else in the stylesheet affecting the scrollbar:

    * {
      background: rgb(23, 29, 40);
      color: rgb(112, 123, 148);
    }
    
    QPushButton {
      background: rgb(38, 46, 60);
      color: rgb(161, 170, 190);
      border-radius: 4px;
      padding: 0.5ex 2ex;
      font-weight: bold;
    }
    
    QPushButton::hover {
      background: rgb(85, 95, 112);
      color: rgb(255, 255, 255);
    }
    
    QPushButton::pressed {
      background: rgb(255, 217, 122);
      color: rgb(19, 24, 32);
    }
    
    QPlainTextEdit, QLineEdit {
      background: rgb(33, 40, 51);
      color: rgb(139, 149, 161);
      border: none;
      padding: 1ex;
    }
    
    QScrollBar {
      width: 4px;
      background: red; /*rgb(42, 53, 65);*/
    }
    
    QScrollBar::handle {
      border: none;
      background: rgb(85, 95, 112);
    }
    
    M 1 Reply Last reply
    0
    • M mnbv

      With Qt 6.4.2, Windows 10, and a stylesheet applied to QScrollBar, I'm having trouble setting the background color of the scroll bar. Whatever color I set always seems to have a white tint applied to it.

      For example, when I set the background color to black, the actual color is a light gray:

      enter image description here

      When I set it to red, the actual color is a light pink.

      Furthermore, I noticed that when I take a screenshot, the color in the screenshot is sometimes correct and doesn't match what I actually saw on the screen. I have no idea why, and it makes it hard to share good screenshots in this post (screenshots of my red one show actual pure red even though it's light pink on the screen).

      What is going on?

      Here is my full stylesheet (which is being set on qApp), just in case it's a matter of something else in the stylesheet affecting the scrollbar:

      * {
        background: rgb(23, 29, 40);
        color: rgb(112, 123, 148);
      }
      
      QPushButton {
        background: rgb(38, 46, 60);
        color: rgb(161, 170, 190);
        border-radius: 4px;
        padding: 0.5ex 2ex;
        font-weight: bold;
      }
      
      QPushButton::hover {
        background: rgb(85, 95, 112);
        color: rgb(255, 255, 255);
      }
      
      QPushButton::pressed {
        background: rgb(255, 217, 122);
        color: rgb(19, 24, 32);
      }
      
      QPlainTextEdit, QLineEdit {
        background: rgb(33, 40, 51);
        color: rgb(139, 149, 161);
        border: none;
        padding: 1ex;
      }
      
      QScrollBar {
        width: 4px;
        background: red; /*rgb(42, 53, 65);*/
      }
      
      QScrollBar::handle {
        border: none;
        background: rgb(85, 95, 112);
      }
      
      M Offline
      M Offline
      mnbv
      wrote on last edited by
      #2

      Nevermind I figured it out. I had to clear the background on ::add-page and ::sub-page:

      QScrollBar::add-page, QScrollBar::sub-page {
          background: none;
      }
      
      1 Reply Last reply
      0
      • M mnbv 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