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. Why does changing the stylesheet of horizontal QScrollBar make vertical QScrollbar appear?
Forum Updated to NodeBB v4.3 + New Features

Why does changing the stylesheet of horizontal QScrollBar make vertical QScrollbar appear?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 504 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.
  • A Offline
    A Offline
    AAhusk
    wrote on last edited by
    #1

    I have a QScrollArea(we'll call scroll area 1) that has only vertical scrolling enabled, and within that scroll area, I have another QScrollArea(we'll call scroll area 2) that has only horizontal scrolling enabled. Right now, I have the scroll area 1 small enough that no scrolling is necessary, so the vertical scroll bar doesn't appear. However, for some reason, changing one small thing on the stylesheet for the horizontal QScrollBars will make the vertical scroll bar appear in scroll area 1.

    Here is a screenshot before making any stylesheet changes whatsoever to QScrollBar:
    ScrollBar1.png

    And then after simply adding

    QScrollBar::handle:hover:horizontal {
      background: #016894;
    }
    

    to the .qss file, the scrollbar on the right can now be seen:
    Scrollbar2.png

    Note that the scroll arrows are also gone, but that's a more intuitive result of me only changing one subcontrol, state, and property. Because I did see in the docs(https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qscrollbar) that "if one property or sub-control is customized, all the other properties or sub-controls must be customized as well.".

    So I could see how messing with part of QScrollBar style, but not all of it, could ruin other parts of the QScrollBar style. But I'm not sure why it would affect whether or not a scroll bar is hidden? The thing is, I know how to add the arrows back in, but I don't know what about the style causes that vertical scroll bar to suddenly appear; I don't know how to get rid of it by adjusting the stylesheet.

    Thanks.

    1 Reply Last reply
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @AAhusk,

      QScrollBar::handle:hover:horizontal

      I believe it should be:

      QScrollbar::handle:horizontal:hover
      

      ie horizontal before the hover?

      Cheers.

      A 1 Reply Last reply
      0
      • Paul ColbyP Paul Colby

        Hi @AAhusk,

        QScrollBar::handle:hover:horizontal

        I believe it should be:

        QScrollbar::handle:horizontal:hover
        

        ie horizontal before the hover?

        Cheers.

        A Offline
        A Offline
        AAhusk
        wrote on last edited by
        #3

        @Paul-Colby After testing, it doesn't seem to make a difference what order horizontal and hover are in.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          Well, if the documentation already says that you might need to modify all properties (as you have mentioned), then this certainly also includes the height of the scroll bar. It might be ever so slightly higher than before which would force the vertical scroll bar to show.

          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