Why my scrollbar track color is transparent?
-
This post is deleted!
-
-
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.
-
@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. -
@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.
-
@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; }
-
@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. -
@Ishaq-Khan
what platform?
what OS?
did you set any other stylesheet somewhere else? -
@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.
-
Hi
It seems you mean like this
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