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 my scrollbar track color is transparent?
QtWS25 Last Chance

Why my scrollbar track color is transparent?

Scheduled Pinned Locked Moved Solved General and Desktop
scroll barstylesheetpyqt5pyside2pyqt
11 Posts 3 Posters 5.5k 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.
  • I Offline
    I Offline
    Ishaq Khan
    wrote on 5 Jul 2019, 08:41 last edited by Ishaq Khan 7 May 2019, 14:09
    #1
    This post is deleted!
    R 1 Reply Last reply 5 Jul 2019, 10:27
    0
    • I Ishaq Khan
      5 Jul 2019, 08:41

      This post is deleted!

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 5 Jul 2019, 10:27 last edited by
      #2

      @Ishaq-Khan
      https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qscrollbar

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • I Offline
        I Offline
        Ishaq Khan
        wrote on 5 Jul 2019, 12:39 last edited by
        #3

        Don't you know stylesheets are inherited by child widgets in Qt? If I add:

        t.verticalScrollBar().setStyleSheet('background: black')
        

        It will still have no effect.

        I think my question is not well understood, I am updating my question.

        Thanks for your helping.

        R 1 Reply Last reply 5 Jul 2019, 12:42
        0
        • I Ishaq Khan
          5 Jul 2019, 12:39

          Don't you know stylesheets are inherited by child widgets in Qt? If I add:

          t.verticalScrollBar().setStyleSheet('background: black')
          

          It will still have no effect.

          I think my question is not well understood, I am updating my question.

          Thanks for your helping.

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 5 Jul 2019, 12:42 last edited by
          #4

          @Ishaq-Khan said in Why my scrollbar track color is transparent?:

          Don't you know stylesheets are inherited by child widgets in Qt?

          sure i know.
          But not every part of a widget drawn is also a child widget, but a subcontrol inside the style painting the widget.
          So go ahead and read my link again and adapt your stylesheet.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          I 1 Reply Last reply 5 Jul 2019, 12:55
          0
          • R raven-worx
            5 Jul 2019, 12:42

            @Ishaq-Khan said in Why my scrollbar track color is transparent?:

            Don't you know stylesheets are inherited by child widgets in Qt?

            sure i know.
            But not every part of a widget drawn is also a child widget, but a subcontrol inside the style painting the widget.
            So go ahead and read my link again and adapt your stylesheet.

            I Offline
            I Offline
            Ishaq Khan
            wrote on 5 Jul 2019, 12:55 last edited by Ishaq Khan 7 May 2019, 12:55
            #5

            @raven-worx
            But at least stylesheets are inherited by sub-controls too. That was the point.

            And again thanks for providing that link. I have already visited it before posting my question. I can't get any help from it.

            Well I have updated my question. Please view the image provided or at least run my code to see the problem. Thanks.

            R 1 Reply Last reply 5 Jul 2019, 13:01
            0
            • I Ishaq Khan
              5 Jul 2019, 12:55

              @raven-worx
              But at least stylesheets are inherited by sub-controls too. That was the point.

              And again thanks for providing that link. I have already visited it before posting my question. I can't get any help from it.

              Well I have updated my question. Please view the image provided or at least run my code to see the problem. Thanks.

              R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 5 Jul 2019, 13:01 last edited by
              #6

              @Ishaq-Khan said in Why my scrollbar track color is transparent?:

              But at least stylesheets are inherited by sub-controls too. That was the point.

              if the stylesheet contains subcontrol rules, if you want so.

              Then try this stylesheet as a starting point and adapt it to your needs:

              QWidget {
                   background: black; 
                   color: white; 
                   font-size: 12pt
              }
              
              QScrollBar:horizontal {
                  border: 2px solid grey;
                  background: black;
                  height: 15px;
                  margin: 0px 20px 0 20px;
              }
              QScrollBar::handle:horizontal {
                  background: white;
                  min-width: 20px;
              }
              QScrollBar::add-line:horizontal {
                  border: 2px solid grey;
                  background: black;
                  width: 20px;
                  subcontrol-position: right;
                  subcontrol-origin: margin;
              }
              
              QScrollBar::sub-line:horizontal {
                  border: 2px solid grey;
                  background: black;
                  width: 20px;
                  subcontrol-position: left;
                  subcontrol-origin: margin;
              }
              

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              I 1 Reply Last reply 5 Jul 2019, 13:25
              1
              • R raven-worx
                5 Jul 2019, 13:01

                @Ishaq-Khan said in Why my scrollbar track color is transparent?:

                But at least stylesheets are inherited by sub-controls too. That was the point.

                if the stylesheet contains subcontrol rules, if you want so.

                Then try this stylesheet as a starting point and adapt it to your needs:

                QWidget {
                     background: black; 
                     color: white; 
                     font-size: 12pt
                }
                
                QScrollBar:horizontal {
                    border: 2px solid grey;
                    background: black;
                    height: 15px;
                    margin: 0px 20px 0 20px;
                }
                QScrollBar::handle:horizontal {
                    background: white;
                    min-width: 20px;
                }
                QScrollBar::add-line:horizontal {
                    border: 2px solid grey;
                    background: black;
                    width: 20px;
                    subcontrol-position: right;
                    subcontrol-origin: margin;
                }
                
                QScrollBar::sub-line:horizontal {
                    border: 2px solid grey;
                    background: black;
                    width: 20px;
                    subcontrol-position: left;
                    subcontrol-origin: margin;
                }
                
                I Offline
                I Offline
                Ishaq Khan
                wrote on 5 Jul 2019, 13:25 last edited by
                #7

                @raven-worx
                But scrollbar track (or where scrollbar handle moves) is still not solid color. Its showing some pattern/texture. You can see it in image I provided.

                R 1 Reply Last reply 5 Jul 2019, 13:30
                0
                • I Ishaq Khan
                  5 Jul 2019, 13:25

                  @raven-worx
                  But scrollbar track (or where scrollbar handle moves) is still not solid color. Its showing some pattern/texture. You can see it in image I provided.

                  R Offline
                  R Offline
                  raven-worx
                  Moderators
                  wrote on 5 Jul 2019, 13:30 last edited by
                  #8

                  @Ishaq-Khan
                  what platform?
                  what OS?
                  did you set any other stylesheet somewhere else?

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  I 1 Reply Last reply 5 Jul 2019, 13:50
                  0
                  • R raven-worx
                    5 Jul 2019, 13:30

                    @Ishaq-Khan
                    what platform?
                    what OS?
                    did you set any other stylesheet somewhere else?

                    I Offline
                    I Offline
                    Ishaq Khan
                    wrote on 5 Jul 2019, 13:50 last edited by Ishaq Khan 7 May 2019, 14:19
                    #9

                    @raven-worx
                    My Python version is 3.7.
                    My computer OS is Windows 10 (x64).
                    No, I have not set any more CSS somewhere else in the script too; The code I provided is a complete code.

                    I have used stylesheets a lot and have much experience with it. But this problem appears to be not related to stylesheets. But still can't say its a bug. Maybe I (or we) have insufficient knowledge to understand and solve this.

                    Please help me, this is one of few problems holding my project from to be completed.

                    1 Reply Last reply
                    0
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 5 Jul 2019, 19:28 last edited by
                      #10

                      Hi
                      It seems you mean like this
                      alt text
                      Please see here.
                      https://stackoverflow.com/questions/17935691/stylesheet-on-qscrollbar-leaves-background-of-scrollbar-with-checkerboard-patter
                      (its actually covered by mr @raven-worx but just in case)

                      Tested on windows 10
                      alt text

                      I 1 Reply Last reply 11 Jul 2019, 08:26
                      1
                      • mrjjM mrjj
                        5 Jul 2019, 19:28

                        Hi
                        It seems you mean like this
                        alt text
                        Please see here.
                        https://stackoverflow.com/questions/17935691/stylesheet-on-qscrollbar-leaves-background-of-scrollbar-with-checkerboard-patter
                        (its actually covered by mr @raven-worx but just in case)

                        Tested on windows 10
                        alt text

                        I Offline
                        I Offline
                        Ishaq Khan
                        wrote on 11 Jul 2019, 08:26 last edited by
                        #11

                        @mrjj Thank you very much! Problem solved.

                        1 Reply Last reply
                        1

                        2/11

                        5 Jul 2019, 10:27

                        topic:navigator.unread, 9
                        • Login

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