Erasing on transparent widget
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?
Re: Erasing on transparent widget
I am not sure how it is with transparent color, but have you tried to play around with QPainter::setCompositionMode()?
Re: Erasing on transparent widget
Hi Lykurg, thanks for the reply.
I've tried every composition mode. None seem to work.
Re: Erasing on transparent widget
setAutoFillBackground(TRUE);
or try:-
setAttribute(Qt::WA_TranslucentBackground,true );
Re: Erasing on transparent widget
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
Re: Erasing on transparent widget