How to make brackground transparent
I’ve built a custom QScrollArea-based widget, but it’s default background was some color. I’d like to make background transparent so that it could display widgets which were even under it if overlapped.
However I didn’t see there’s a transparent role in setBackgroundRole(), then how could I do?
thx.
10 replies
setAutoFillBackground didn’t simply work.
WA_NoBackground was obsolete and the successor WA_OpaquePaintEvent said in opposite way, and didn’t work either.
WA_NoSystemBackground and WA_TranslucentBackground ended up with a little bit repainting issue, since it never automatically updated newly exposed area, for instance. Then the tough part would turn to that I have to paint everything underneath the widget.
If memory severed me, QFrame is by default transparent, don’t know how it get that.
You can try, setting these attributes on the widget:
- setAttribute(Qt::WA_NoBackground);
- setAttribute(Qt::WA_NoSystemBackground);
- setAttribute(Qt::WA_TranslucentBackground);
additionally, you could set setAutoFillbackground(false).
my fault, I didnt
#include <qscrollbar.h>
- scroll_gunshop->verticalScrollBar()->setStyleSheet("background-color:red");
but there is still a little “pattern” in there.
the part where the scroll bar is not covered.
http://img534.imageshack.us/img534/2594/ddddiw.jpg
but looks almost perfect.
thanks*
€ or maybe this is just the normal “natural” scroll bar pattern
if you use white it’s gone.
You can customize everything in the scrollbar just by using css… try taking a look here [doc.qt.digia.com] and try out different css commands…
You must log in to post a reply. Not a member yet? Register here!


