[Qt-interest] painting on a widget

Alexandre Beraud aberaud at infflux.com
Mon Jan 12 09:57:43 CET 2009


Hi Darryl,

As far as I know, you have to create a transparent QWidget and make sure 
it is always raised. You can then paint on it.
In the constructor of the derived class, use:
setAttribute(Qt::WA_TransparentForMouseEvents);
setAutoFillBackground(false);
setMouseTracking(true);
I hope it helps.
Regards,

Alex


Darryl Hunter a écrit :
>
> Hi all,
>
> I have a widget that has several layouts / widgets displayed on it. 
> All is good.
>
> Under a certain circumstance I want to draw a circle on the widget on 
> top of everything else. So in my widgets paintEvent() method I do:
>
> QPainter painter
>
> painter.begin (this);
>
> helper->paint (&painter, event);
>
> painter.end
>
> Within my Helper::paint() method, I do:
>
> painter->drawEllipse (…).
>
> However it draws this ellipse behind the other components of the 
> widget. I want it to be in front of.
>
> With the Graphics Scene there is a Z value which would take care of 
> this. How do I do this with the normal painter?
>
> Thanks.
>
> Darryl
>
> ----------------------------------------------------------------------------
>
> Darryl Hunter
> Director
> CoderSoft Pty Ltd
>
> (m) 04 5060 6804
> darryl.hunter at codersoft.com.au <mailto:darryl.hunter at codersoft.com.au>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com





More information about the Qt-interest-old mailing list