Overloading QGraphicsView::drawItems is exactly where I need to do my specific computation.
So I can call myself the paint of each items with something like I found in the docs and in some QGraphicsScene implementation from koders site at http://www.koders.com/cpp/fidF0D7D36...eneMatrix#L948 :
for(int i=0;i<numItems;i++) {
painter->save();
painter->setMatrix(items[i]->sceneMatrix(), true);
items[i]->paint(painter, &options[i], this);
painter->restore();
}
}
void QMyGraphicsView:drawItems(QPainter * painter, int numItems, QGraphicsItem * items[], const QStyleOptionGraphicsItem options[]) {
for(int i=0;i<numItems;i++) {
painter->save();
painter->setMatrix(items[i]->sceneMatrix(), true);
items[i]->paint(painter, &options[i], this);
painter->restore();
}
}
To copy to clipboard, switch view to plain text mode
But I encountered some disagreements. It seems that the default implementation of drawItems is more complicated than that :
* The items with flag QGraphicsItem::ItemIgnoresTransformations are not rendered properly with the loop I wrote
* The items cached with QGraphicsItem::DeviceCoordinateCache are painted for each call of drawItems, while the default drawItems save a lot of paintings.
Does anyone knows where I can find the real default implementation of QGraphicsScene::drawItems according to item flags?
I will investigation myself on changing my design to do my computation and set attributes of the item of my scene, then call the default drawItems.
Bookmarks