PDA

View Full Version : Regarding QGraphicsView



kiranraj
21st December 2006, 07:24
Hello Guys..

Could any one help me in knowing how QGraphicsView is better than QCanvas (Qt3.3.6).
I have read the documenation which says...
QGraphicsView uses BSP's to manage the scene..But i would like to know how it is better than the
Chunks concept used in Qt3 in terms of space and time wise..

Thanx

e8johan
21st December 2006, 07:56
The graphics view is better in many other ways - it has been adapted to all the experiences gained during the years with the canvas.

As for BSP trees vs chunks. I'm not sure about the chunks, but BSP trees are O(logn) complex which can be considered good.

kiranraj
21st December 2006, 09:12
I know that searching items on the canvas takes O( log n) ...
But what about the space complexity ....?
Thanx..

wysota
21st December 2006, 09:38
Could any one help me in knowing how QGraphicsView is better than QCanvas (Qt3.3.6).
As Johan mentioned, it has many advantages. It's more scalable (QCanvas was designed to hold thousands of items, QGraphicsScene can easily handle even a milion items without a major slowdown), easier to handle thanks to the use of local coordinate systems for each item, has more capabilities - for example each item can handle events passed to it and many more. Most of it is mentioned in the docs.


But i would like to know how it is better than the
Chunks concept used in Qt3 in terms of space and time wise..
In most cases it is better. For other cases (when you have many moving items that would have to be constantly moved between leaves of the tree) you can turn off BSP indexing.



I know that searching items on the canvas takes O( log n) ...
But what about the space complexity ....?
QGraphicsItem uses not more than several bytes of RAM as most data has been moved to more specialised classes (for example animation support was moved to QGraphicsItemAnimation), that's why it's more scalable than QCanvas.

If you're in doubt whether you should use QCanvas or switch to Qt4 and use QGraphicsView framework then in 99.9% of cases you should do the latter.

kiranraj
22nd December 2006, 04:59
Thanx for the reply .....:)