PDA

View Full Version : Erasing on transparent widget



mooklekloon
11th March 2010, 22:01
I have a widget with a transparent background.

setAttribute(Qt::WA_OpaquePaintEvent,true);
setPalette(QPalette(Qt::transparent));

I draw some stuff on the widget

QPainter p(this);
p.fillRect(0,0,10,10,Qt::black);

I would now like to erase the rectangle so that the area is once again transparent and the widgets underneath show through. I can't seem to figure out out to do this.

p.fillRect(0,0,10,10,Qt::transparent); doesn't work.

Any ideas?

Lykurg
11th March 2010, 22:40
I am not sure how it is with transparent color, but have you tried to play around with QPainter::setCompositionMode()?

mooklekloon
11th March 2010, 22:48
Hi Lykurg, thanks for the reply.
I've tried every composition mode. None seem to work.

user_mail07
12th March 2010, 00:54
setAutoFillBackground(TRUE);

or try:-
setAttribute(Qt::WA_TranslucentBackground,true );

mooklekloon
12th March 2010, 01:25
No luck :(

Current setup:

setAttribute(Qt::WA_OpaquePaintEvent,true);
setAttribute(Qt::WA_TranslucentBackground,true);
setAutoFillBackground(true);
setPalette(Qt::transparent);

calling p.eraseRect... doesn't seem to erase anything

mooklekloon
12th March 2010, 16:53
Anyone? Please :(