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. Edit scrollbar colour through stylesheet in main window?
Forum Updated to NodeBB v4.3 + New Features

Edit scrollbar colour through stylesheet in main window?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qscrollbarmainwindowstylesheetscrollscrollbar
6 Posts 3 Posters 1.5k 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.
  • H Offline
    H Offline
    Hologram
    wrote on 27 Jan 2023, 14:17 last edited by Hologram
    #1

    Hi, I am modifying an existing stylesheet and was wondering how I modify the main scrollbars? You can see one to the right hand side of the screen.
    c7c7c904-8155-49e6-b470-ab2ce990a774-afbeelding.png

    AFAICT it is not in the QScrollbar::vertical class, which controls other scrollbars, so where should I look/ which lines could I add to the stylesheet to get rid of the arrow buttons and change the background, the handle background and the hover background color?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Jan 2023, 19:39 last edited by
      #2

      Hi,

      Is it the vertical scrollbar of a QScrollArea ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply 27 Jan 2023, 23:11
      0
      • S SGaist
        27 Jan 2023, 19:39

        Hi,

        Is it the vertical scrollbar of a QScrollArea ?

        H Offline
        H Offline
        Hologram
        wrote on 27 Jan 2023, 23:11 last edited by
        #3

        @SGaist No, I think it isn't. That's because I already styled the vertical scrollbar: and these are very different in terms of colours than the scrollbar in the picture above.

        QAbstractScrollArea {
            border-radius: 2px;
            background-color: #303030; /*View tabs background bar */
        }
        
        QAbstractScrollArea::corner {
            border: none;
            background-color: transparent;
        }
        
        QScrollBar::handle:vertical,
        QScrollBar::handle:horizontal {
            background-color: #3E3E3E; /* Adjusts scrollbar handle color */
        }
        
        QScrollBar::handle:vertical:hover,
        QScrollBar::handle:horizontal:hover {
            background-color: #545454; /* Adjusts scrollbar handle color upon hover */
        }
        
        QScrollBar:vertical {
            background-color: #303030; /* Adjusts scrollbar background color */
            width: 15px;
            margin: 0px;
        }
        
        QScrollBar::handle:vertical {
            min-height: 5px;
            border-radius: 3px;
            margin: 0px 4px; 
        }
        
        QScrollBar::sub-line:vertical {
            /*margin: 3px 0px 3px 1px; /* Enabled by default to show handles */
            /*border-image: url(qss:images_dark-light/up_arrow_light.svg);*/ /* Enables/Disables up arrow in horizontal scrollbar*/
            height: 0px; /* By default: 4px 15px; to create space for arrows*/
            width: 10px;
            subcontrol-position: top;
            subcontrol-origin: margin;
        }
        
        QScrollBar::add-line:vertical {
            /*margin: 3px 0px 3px 1px;*/ /* Enabled by default to show handles */
            /*border-image: url(qss:images_dark-light/down_arrow_light.svg);*/ /* Enables/Disables down arrow in horizontal scrollbar*/
            height: 0px; /* By default: 4px 15px; to create space for arrows*/
            width: 10px;
            subcontrol-position: bottom;
            subcontrol-origin: margin;
        }
        
        QScrollBar::sub-line:vertical:hover,
        QScrollBar::sub-line:vertical:on {
            border-image: url(qss:images_dark-light/up_arrow_lighter.svg);
        }
        
        QScrollBar::add-line:vertical:hover,
        QScrollBar::add-line:vertical:on {
            border-image: url(qss:images_dark-light/down_arrow_lighter.svg);
        }
        
        QScrollBar::up-arrow:vertical,
        QScrollBar::down-arrow:vertical {
            background-color: none;
        }
        
        QScrollBar::add-page:vertical,
        QScrollBar::sub-page:vertical {
            background-color: transparent;
        }
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Jan 2023, 10:24 last edited by
          #4

          Hi
          What I normally do is to call
          https://doc.qt.io/qt-6/qobject.html#dumpObjectTree

          for the parent, I think holds the element I want to change. That way I can see types and names (if any) and
          how they are nested.

          It's shown in the Application output pane in Creator

          H 1 Reply Last reply 28 Jan 2023, 11:53
          0
          • M mrjj
            28 Jan 2023, 10:24

            Hi
            What I normally do is to call
            https://doc.qt.io/qt-6/qobject.html#dumpObjectTree

            for the parent, I think holds the element I want to change. That way I can see types and names (if any) and
            how they are nested.

            It's shown in the Application output pane in Creator

            H Offline
            H Offline
            Hologram
            wrote on 28 Jan 2023, 11:53 last edited by
            #5

            @mrjj sorry, I don't understand what you mean.
            I am only modifying a stylesheet in VSCode, I don't have any controls over the UI coding of the application. I can only modify the stylesheet. I wouldn't know where to look to see the classes.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Jan 2023, 16:37 last edited by
              #6

              Don't you have access to the source code ?
              And if not, ask the authors ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              2/6

              27 Jan 2023, 19:39

              topic:navigator.unread, 4
              • Login

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