[Qt-qml] Using QML canvas from C++, like QGraphicsView

Ville M. Vainio vivainio at gmail.com
Wed Jan 19 12:26:02 CET 2011


On Wed, Jan 19, 2011 at 1:07 PM,  <alan.alpert at nokia.com> wrote:

> Perhaps I'm just dwelling on the mention of implementing the animation in C++. If this case is merely that you don't want to write any game logic in Javascript you can do the logic part in C++, setting the x/y of the Items, and have that animated with Behaviors. One way this could be done would be to create a custom QObject exposed to QML containing the game logic, and with properties that get set to the relevant entities in QML. By getting the QDeclarativeItem pointers, and thus setting x/y directly instead of through the property system, the performance hit compared to using straight GraphicsView will be insignificant (although the startup time might be slightly longer, that shouldn't be significantly longer either).

Thanks, this is pretty much what I was after. I am trying to argue the
case that you shouldn't dismiss QML-enabling your application just
because you'd rather use C++ for everything (or you have significant
body of non-opengl game logic code already written in C++). That is,
the QML canvas is the place where you want to draw in the future, no
matter how you write the code.

-- 
Ville M. Vainio @@ Forum Nokia


More information about the Qt-qml mailing list