PDA

View Full Version : QPainter rotate function



ir210
16th January 2006, 04:04
Hi,

I have problem with QCanvas since the beginning of my development time with qt. My newest problem is with QPainter inside QCanvasPolygonalItem's subclass.

Here is my code.


void drawShape(QPainter* p)
{
p.rotate(45);
p.drawRect(x(), y(), width(), height() ); // or something similiar, I forget
p.rotate(-45); // as suggested in documentation
}


I found it flickering at runtime. anyone could help me with this problem? since flickering is my only problem with QCanvas.

sunil.thaha
16th January 2006, 06:26
To avoid flickering use the Double buffereing technique.
Paint to another pixmap and use bitblt to draw it to the canvas

The technique is explained in the C++ GUI Programming with Qt 3

jacek
16th January 2006, 18:09
To avoid flickering use the Double buffereing technique.
Paint to another pixmap and use bitblt to draw it to the canvas
QCanvas has built-in support for double buffering.


void QCanvas::setDoubleBuffering ( bool y ) [virtual]
If y is TRUE (the default) double-buffering is switched on; otherwise double-buffering is switched off.
Turning off double-buffering causes the redrawn areas to flicker a little and also gives a (usually small) performance improvement.

sunil.thaha
17th January 2006, 05:31
Thanks Jacek