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. Customizing vertical and horizontal Scrollbars at the same time with css
Forum Updated to NodeBB v4.3 + New Features

Customizing vertical and horizontal Scrollbars at the same time with css

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.2k 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.
  • B Offline
    B Offline
    b1gsnak3
    wrote on last edited by
    #1

    Hello!

    I have a widget inside of a QScrollArea and I want to customize the ScrollBars with css. When only one ScrollBar is enabled, the css works fine but when both are enabled, the sub-page and add-page controls lose their css. Anyone know why this is happening and how I can work around it? Any help would be much appreciated.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Can you show some code that gives you trouble?
      I checked and it seems to work fine:

      @
      scrollArea->setStyleSheet( "QScrollBar { border: none; }"
      "QScrollBar::sub-page:horizontal { background-color: red; }"
      "QScrollBar::add-page:horizontal { background-color: green; }"
      "QScrollBar::sub-page:vertical { background-color: blue; }"
      "QScrollBar::add-page:vertical { background-color: yellow; }"
      );
      @

      The result is:
      !http://img845.imageshack.us/img845/448/scrollbars.jpg(scrollbars example)!

      1 Reply Last reply
      0
      • B Offline
        B Offline
        b1gsnak3
        wrote on last edited by
        #3

        when I set it to transparent it doesn't behave like this... It gives a grayish color like the normal color of a widget... Code is irrelevant because it works when only one of the scrollbars is visible...

        @QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
        background: transparent;
        }

        QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
        background: transparent;
        }@

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok, I get what you mean, transparency works a little different.
          The add-page and sub-page become transparent, but they are "on top" of the QScrollBar, so it's default background is visible (gray). Also, the scrollbars are not "on top" of the scroll area content, they are beside it, so to get a common background for content and scrollbars you need to set it on the QScrollArea itself, and give the content transparent background.

          Example:
          @
          QScrollArea { background-color: red; }

          #scrollAreaWidgetContents { background-color: transparent; }

          QScrollBar { background-color: transparent; }

          QScrollBar::sub-page,
          QScrollBar::add-page { background-color: transparent; }
          @
          gives
          !http://img402.imageshack.us/img402/5166/scrollbars2.jpg(scrollbar example 2)!

          1 Reply Last reply
          0

          • Login

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