PDA

View Full Version : QPainter::setClipPath



scascio
1st December 2009, 16:08
Hi everyone,

Did anyone succeed in setting a clip path with QPainter::setClipPath?

I verifyied carefully my coordinates and they are right since QPainter::fillPath works. I dont want to set a mask to the QImage since I use QPainter::drawImage(const QRectF&, const QImage&, const QRectF&) and I dont want to copy neither scale the image buffer I use in drawing.

I tried a lots of commands without success in the paint event of a QGraphicsItem. Setting a clip path that is filled with polygons cancel the image painting instructions I use later.

Here are some of my unsuccessful tries :


painter->setClipping(true);(
painter->setClipPath(shape());
painter->drawImage(exposedSceneRect, *imageBuffer, rectInPixels);


QPainterPath path;
path.addRect(exposedSceneRect);
path = path.subtracted(shape());

painter->setClipRect(exposedSceneRect);
painter->setClipPath(path, Qt::IntersectClip);
painter->drawImage(exposedSceneRect, *imageBuffer, rectInPixels);


QPainterPath path;
path.addRect(exposedSceneRect);
painter->setClipPath(path.intersected(shape()));

Thanks for any help.

scascio
2nd December 2009, 16:56
Seems that my problem is related with QGLWidget.

When GL viewport is disable, every display operations are fine