PDA

View Full Version : Setting a transparent background to QScrollbar using stylesheets



marwyn
16th June 2011, 09:57
Hi,

I am currently trying to set a scrollbar with completely transparent background.

It works well for the part under the handler, which is completely transparent, but in the part where the handler is not, some kind of white canvas remains...

See a picture in the attachment.

Here's the stylesheet I use for Scrollbars:


QScrollBar:vertical {
background: transparent;
width: 19px;
padding: 0 0 20px 0;
margin: 20px 0 20px 0;
}
QScrollBar::handle:vertical {
background: transparent;
border-image: url(scrollbar.png) 4 0 4 0 repeat;
border-top: 4px;
border-bottom: 4px;
min-height: 39px;
}
QScrollBar::add-line:vertical {
border-top: solid 5px transparent;
background: none;
height: 20px;
subcontrol-position: bottom;
subcontrol-origin: padding;
}
QScrollBar::sub-line:vertical {
border: none;
background: none;
height: 20px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical{
image: url(uparrow.png);
}
QScrollBar::down-arrow:vertical{
image: url(downarrow.png);
}


Any idea ?

Thanks a lot.
Márwyn

Rachol
16th June 2011, 10:33
Yes, there is some bug/feature in rendering the background for scrollbar :)

In my opinion the implementation of drawing widgets with stylesheets is a little bit messy. Certain parts are drawn using stylesheets, some other using current style, some other hardcoded style. Therefore if you run your application on Linux, you don't get the problem that you get on your Windows machine.

Try to run your app with different style that Windows default and see what happens

marwyn
16th June 2011, 10:56
Thanks a lot !
Setting the scrollbar style to another style did the trick !

myScrollbar->setStyle( new QCommonStyle );

Still, this is (a bit) hacky... Is there no clean way to do that ?
Anyway, it will do for now, until I find something else :)

Thx again !
Márwyn