PDA

View Full Version : Passing a value between QtScript and QML?



Lendrick
21st January 2012, 21:36
Greets!

I'm building a game engine (http://gitorious.org/orange-engine) on Qt 4.x, and I've run into a situation where I need to pass objects between QtScript (which I'm using for game scripting) and QML (which I'm using for the UI). I'm using the QDeclarativeDebugHelper hack to grab the script engine from the QDeclarativeEngine object, so both my QML and QtScript share the same root object. This works really well except when I try to pass an object from QtScript to a QML method, in which case the object is changed from a QObject reference to a QVariantMap. Is there any way I can prevent this?

Before anyone asks, I'm not going to rearchitect my entire code base due to this one problem. The answer to "why would you want to do it this way?" is that I'm essentially committed to it at this point and one silly little issue (that *ought* to be fixable) is preventing everything from working smoothly. :)