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?
Forum Updated to NodeBB v4.3 + New Features

Why my scrollbar track color is transparent?

Scheduled Pinned Locked Moved Solved General and Desktop
scroll barstylesheetpyqt5pyside2pyqt
11 Posts 3 Posters 6.0k Views 3 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.
  • I Ishaq Khan

    This post is deleted!

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on 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 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.

      raven-worxR 1 Reply Last reply
      0
      • I Ishaq Khan

        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.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on 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
        0
        • raven-worxR raven-worx

          @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 last edited by Ishaq Khan
          #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.

          raven-worxR 1 Reply Last reply
          0
          • I Ishaq Khan

            @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.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on 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
            1
            • raven-worxR raven-worx

              @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 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.

              raven-worxR 1 Reply Last reply
              0
              • I Ishaq Khan

                @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.

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on 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
                0
                • raven-worxR raven-worx

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

                  I Offline
                  I Offline
                  Ishaq Khan
                  wrote on last edited by Ishaq Khan
                  #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 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
                    1
                    • mrjjM mrjj

                      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 last edited by
                      #11

                      @mrjj Thank you very much! Problem solved.

                      1 Reply Last reply
                      1

                      • Login

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