[Qt-interest] How to draw outside QPaintEvent.

R. Reucher rene.reucher at batcom-it.net
Tue Apr 7 11:04:14 CEST 2009


On Tue April 7 2009 09:49:10 sathya tej wrote:
> I need to draw circles out side QPaintEvent.
Then why not paint them to non-QWidget paint device like a QImage and "blit" 
the image data to the QWidget during its paintEvent() (using 
QPainter::drawImage() for example)?!

> I have used* setAttribute(Qt::WA_PaintOutsidePaintEvent,true);* but in
> vain.
Note that this attribute is only honored on X11 platforms... but then again, 
I'm not sure if it gets you any advantages here.

> Please tell me when  *void paintEvent(QPaintEvent *event) *is called by Qt.
> Will it be called only once or can it be called multiple times.
As Arnold already told, you can call update() / repaint() at any time... this 
will generate a paintEvent() if necessary (at least once even if not 
necessary).

According to the docs, a paintEvent() will be called when:

  * repaint() or update() was invoked,
  * the widget was obscured and has now been uncovered, or
  * many other reasons.

Whatever "many other reasons" means :) -- the important question is, why would 
you want more than that?

HTH, René
-- 
René Reucher
rene.reucher at batcom-it.net
http://www.batcom-it.net/

The trouble with being punctual is that people think you have nothing
more important to do.




More information about the Qt-interest-old mailing list