I am using QGraphicsView and the best optimization I have found is to write my own QGraphicsItem.
For instance, I manage multi resolution huge images, and I overloaded the paintEvent of a QGraphicsItem derived like this :
void QGraphicsItemResource
::paint(QPainter * painter,
painter->setClipping(true);
painter->setClipRect(options->exposedRect);
painter->drawImage(options->exposedRect, sourceImage, sourceRect);
}
void QGraphicsItemResource::paint(QPainter * painter,
const QStyleOptionGraphicsItem * options,
QWidget *) {
painter->setClipping(true);
painter->setClipRect(options->exposedRect);
painter->drawImage(options->exposedRect, sourceImage, sourceRect);
}
To copy to clipboard, switch view to plain text mode
The thing I want to point out is the use of QPainter::drawImage, that prevent from QPixmap copies and do the scaling automatically during the paint. So the performances are better.
And if you are not using image, but only polygons, try to enable Clipping top minimize painting operation. Another solution is to simplify the geometry according to the scale displayed defore painting the item. In all cases, you will need to implement your own QGraphicsItem.
S.Cascio
Bookmarks