QScrollArea static background-image and QLabels
-
I use style sheet such a:
QWidget { background-attachment: fixed; background-repeat: none; background-image: url(:/unary_function.PNG); }
result on the screen:
I know that i can use for example QScrollArea > QWidget > QWidget but then style sheet will be apply for widgetScrollAreaContents and "background-attachment: fixed" execute wrong. All are ok. But not need apply background-image for labels on QScrollArea!!! ...
Help me pls
-
Hi
QLabels are also QWidgets.
You must specify better whom you want affected.
Using QWidget as selector will take all.If you only have one scrollarea , maybe you can use use names ?
You could also try
QLabel{} in end of stylesheet. -
You set stylesheet on ScrollArea or on mainwindow?
try QLabel{} in end of stylesheet for fast test. might just work.
-
@SHRED4RED
Yep, stylesheets are always cascading. and when selector is QWidget, all children
are affected.If you set a background color QLabel last in sheet. does it show ?
-
@mrjj doesn't show it.
Okey, mb you can explain me: when I use
QWidget
{
...
}
style sheet set for all widgets.but why when I use QScrollArea {...} picture doesn't show at all. Why?
Which widget does set style sheet and show picture? I try QAbstractScrollArea - none, QAbstractScrollArea > QWidget - none, QAbstractScrollArea > QWidget > QWidget = widgetScrollAreaContents - is wrong for me, QAbstractScrollArea > QWidget > QWidget > QWidget = my labels . Okey, but where QWidget which show picture, when i use QWidget{...} because it execute good for me (static picture in area, but bad than Qlabel use properties too :( how i can find this a right QWidget? ) -
Ok it does seem to clear background.
had to change QscrollArea to transparent to see through.
But scrollAreaWidgetContents covers all area so its that you see. -
@SHRED4RED
Its not stupid. :)
StyleSheets is a bit tricky and sometimes its not apparent whom draw what where.
Like Views have a viewport object and QScrollArea also have an internal helper widget.
and i really wish we could write
QWidget, !QLabel {
}
There is some negative/reverse selectors but did not work for me. -
@SHRED4RED
Np. that's why i hang out here.
Remember to mark it solved :)
(ps i bumped your reputation so you dont have to wait x mins to answer)