Basically what I did was to create a declarative engine and not a declarative view. By doing this you can have a QML file interpreted and access to the object instances created by the engine from within your C++ code. I see a lot of potential and possibilities, one thing that comes to my mind straight away is to utilize QML as a Dependency Injection container :)
QDeclarativeEngine *engine = new QDeclarativeEngine; QDeclarativeComponent component(engine, QUrl("qrc:/example1.qml")); Board *board = qobject_cast<board *>(component.create());
Example code to interpret a QML file
Check out the video below which demonstrates my code:
I've also tagged this post with Python because it can be of interest for the planet python readers since this can also be accomplished with PySide.
That is pretty neat. Gave me some ideas too actually. Didn't even think of Python + Arduino combination. With QML it might even be more more interesting.
ReplyDeleteHere are some related projects
http://thp.io/2010/psmove/
http://www.developer.nokia.com/Community/Wiki/index.php/Communicating_with_Arduino
The psmove thingy looks cool, unfortunately I don't have one
ReplyDeleteI actually got an Arduino recently and also though of re-writing this demo for that board but didn't find the time :(
Please keep me updated if you do anything fun!