Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Quick vs Graphics View Framework (QGraphicsScene)

I skimmed through new features of Qt5 and Qt Quick and don't really understand how it differs from the Graphics View Framework (QGraphicsScene) feature wise. It uses QML but beside that:

  1. Can Qt Quick do something that QGraphicsScene can't? For example particle effects.
  2. Is Qt Quick faster than QGraphicsScene? "Faster" meaning more FPS while displaying 1000 moving elements?

I am making a tower defense game and have been using QGraphicsScene and now I wonder whether I should switch to Qt Quick.

like image 864
problemofficer - n.f. Monica Avatar asked Apr 28 '13 20:04

problemofficer - n.f. Monica


People also ask

What is QGraphicsScene?

QGraphicsScene is part of the Graphics View Framework. QGraphicsScene also provides functionality that lets you efficiently determine both the location of items, and for determining what items are visible within an arbitrary area on the scene.

Does QPainter use OpenGL?

QPainter will use hardware accellerated OpenGL calls to draw to QOpenGLPaintDevice instances.

What rendering engine does Qt use?

Qt has two different rendering engines for the Windows platform: OpenGL and DirectX through ANGLE. By default, Qt will try to render using OpenGL.

What is QGraphicsView?

QGraphicsView visualizes the contents of a QGraphicsScene in a scrollable viewport. To create a scene with geometrical items, see QGraphicsScene's documentation. QGraphicsView is part of the Graphics View Framework.


1 Answers

Qt5 and Qt Quick 2 should give a nice performance boost, thanks to "scene graph", which is the underlying engine and basically written from scratch for Qt Quick of Qt5, to take full advantage of OpenGL, and have high frame rate as a design goal from the start.

In addition to performance, I think it count's as a big feature, that you can describe the GUI, transitions, animations and all that, in a much nicer way with QML. There's some learning curve, writing declarative GUI code is quite different from writing more direct C++ code to do similar things, but it's totally worth it.

In Qt4, I don't think QML is going to give any peformance advantage, as I think (did not verify now) there it is written on top QGraphicsView stuff.

So, to summarize: Go for Qt5 and Qt Quick2, and Learn QML for desiging the GUI. Have game logic done in C++ for performance (tower defence games can have quite a bit of stuff happening at the extreme case).

Edit: Blog (old so may be slightly out of date in details) about why then scene graph implementation was created: http://blog.qt.io/blog/2011/05/31/qml-scene-graph-in-master/

like image 104
hyde Avatar answered Oct 14 '22 14:10

hyde