PDA

View Full Version : ClipRect is ignored when drawing a QPainterPath?



wayoda
13th December 2011, 08:15
Hi - here is my setup :
I use a class directly derived from a plain QWigdet as my drawing area overriding paintEvent()
I use a cosmetic pen, anitaliasing is NOT enabled.
I use a clipRect set to the bounding rect of my QWidget.
I draw a simple QPainterPath that has only moveTo and LineTo elements.
The QPainterPath contains at most ~10000 elements.


This is what happens:
When I pouplate my QPainterPath with just enough items to fully cover my drawing area, paintEvents run smoothly.
When I fill up the the Path with more Items painting performance degrades dramatically.

This is my problem:
The strange thing is, all the elements (Lines) I add are located outside the drawing area, so there should be no need to paint them anyway.
I expected the qpainter.drawPath() method to be intelligent enough to skip painting of items outside the drawing surface?
I was a bit surprised because I did a similar thing with Java/Swing/Generalpath. The painting enigne of Java obviously knew which parts of the path where visible and the performance degraded only marginally with the number of items in the GeneralPath.

Any hints how to improve this?
Do I have to implement a custom list of drawing items?
Is the situation any different with the QGraphicsScene/View architecture?

Thanks for reading

Eberhard

wayoda
13th December 2011, 17:28
I'll answer myself..

I dropped the QPainterPath approach in favor of a QVector<QLineF> which I manage myself. Works like a breeze.
I just wonder what a QPainterPath is good for, if the painting system does not know which parts of the item are invisible and therefore don't need to be repainted.

Thanks anyway
Eberhard