[Interest] QGraphicsItem/QGraphicsView - boundingRegion

Christian Gagneraud chgans at gna.org
Mon Oct 5 23:22:56 CEST 2015


On 06/10/15 00:48, Boettger, Heiko wrote:
> Hi,
>
> while looking for a way to optimize the performance on out hardware I
> found the following blog entry:
>
> http://blog.qt.io/blog/2008/01/08/accurate-update-regions-for-thin-qgraphicsitems/

That's quite an old article (2008).

I think there are talking about these:
http://doc.qt.io/qt-5/qgraphicsitem.html#setBoundingRegionGranularity
http://doc.qt.io/qt-5/qgraphicsitem.html#boundingRegion

They have been added in Qt 4.4, which is the Qt version mentioned in the 
article.

A simple optimisation is to cache the values returned by boundingRect() 
and shape() since these function members are called very often (at least 
in my case).

How you tune your view/scene/items depends on the typical use case 
(animated or not, few vs millions of items, big vs small items, ...)

My 2 cents,
Krys

>
> It’s about using a boundingRegion which consist out of multiple
> rectangle in order to reduce the number of pixel to be painted. However
> after looking deeper I got stuck when trying to find out where this
> method is actually called. I used grep to find occurencies of
> “boundingRegion” but the only related call which I could found was in
>
> QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item,
> const QRectF &rect) const
>
> and that method doesn’t seem to be called from code inside qt.
>
> My question is now, does this still work in qt 4.8.7 or 5.4.0? If yes,
> can someone point out where to find information how it works? I am
> interested in the requirements for the CacheMode or other properties to
> make it work. Does the QGraphicsView automatically create such a
> boundingRegion based on the existing QGraphicItems places inside?
>
> Many thanks in advanced.
>
> Heiko Böttger
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>




More information about the Interest mailing list