Hands on QGraphicsScene’s index

Posted by Andreas Aardal Hanssen on December 18, 2006 · 3 comments

Some people have asked if they can have more explicit control over how QGraphicsScene’s index works.

If you’ve got concrete suggestions, please post comments to this post, or send us an email, or post a suggestion through our public feedback form.

Some suggestions we’ve got so far are: setting the depth of the tree, forcing all items to be indexed, blocking item indexing, and so on.

Please, let us know so that we can improve this popular framework. :-)

QShare(this)

Possibly related posts:

  1. Open Governance Mailing list

3 comments

1 Tim December 19, 2006 at 5:29 am
 

I just did lots of profiling of an app I’m writing that uses QGraphicsView.

It has about 300,000 vertices in equal amounts of lines an areas (about 20,000 of them in total). The scale is reasonable (bounding boxes sizes 1×1 to say 300×300, most in the 5×5 range).

Anyway, I found that rendering all this was painfully slow (~0.5 fps), and the QGraphicsScene::items(QRectF….) was taking up loads of ‘cost’ according to valgrind (whatever that is).

So I tried changing the index to no index, and magically it was at least 5 times faster! When zoomed in to a part of the scene (it is a map btw), it was only slightly faster, but still! That’s just crazy.

GraphicsView is nice, but so slow I might resort to writing my own OpenGL BSP thing using a possibly clever overlapping BSP system I think might work.

Speaking of OpenGL, I’ve also noticed that it is *slower* to use it in most cases! What manner of deal is that?

2 eclyptox December 20, 2006 at 6:38 pm
 

Hello!! I am new in qt. Now I am trying to make a program with QGraphicsScene to draw lines or ellipses or polygons. Now I can draw but not with the mouse. I have no idea on how to connect mouse events with the items and its creations.

Thanks.

3 Andreas January 6, 2007 at 4:09 am
 

Tim, you may want to check out the Qt snapshots; there you can set the BSP tree depth explicitly, and the algorithms that calculate the depth automatically are also much better. Is it possible for you to simplify your example and send us a tarball? I could try some profiling, and see what we can improve. If you try the chip demo that comes with Qt, you’ll see that Graphics View itself has no problems with rendering subsets of 40000 items in real-time, and in an earlier post I wrote, I showed how you can even increase that number to 4000000 and still everything is done blindingly fast.

But things can get slow for many reasons. If you send an example, I’m sure we can look at it.

Exlyptox: You should post to qt-interest or on of our community sites (you can find links to several sites if you navigate our web pages).

Comments on this entry are closed.

Previous post:

Next post: