What kind of treatments are we talking about? If you can afford using unstable code, look into Qt 4.6 and the effect classes for graphics items.
What kind of treatments are we talking about? If you can afford using unstable code, look into Qt 4.6 and the effect classes for graphics items.
scascio (30th September 2009)
The treatment involved is histogram stretching, that apply on pixels rendered.
So I need to compute the histogram of the screen (but without labels and polygons), then stretch it.
My problem is that the treatment relies on images displayed and is not independant for each item.
Anyway, QGraphicsEffect in 4.6 seems awesome! Thanks.
The simplest way is to reimplement paint() for all items you want to control and adjusting the colours there. A better way would be to do it once - when each item is created - but it's a bit more work.
I am sorry but I can't see your thought.
How can I get the display result of items painted, then modifiy the result of the paint event with some parameters that depends on the set of items painted?
If I move or zoom, the set of items changes, so the treatement is different.
Reimplement QGraphicsView::drawItems() and do your calculations there.
Thanks for confirming.
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 :
But I encountered some disagreements. It seems that the default implementation of drawItems is more complicated than that :Qt Code:
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
* 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.
Sure it is more complicated. According to me you should only do some calculations of yours there, optionally modify the options and then call the base class implementation from QGraphicsView. The rest has to be done from within the items' paint() routine. Of course be aware that you will probably ruin cached items anyway.
Bookmarks