PDA

View Full Version : QtScript access variable from C++



bunjee
12th January 2009, 20:04
Hey there,

I'm using QtScript on Qt 4.4.

I have the following scenario:


main.prototype.body = function()
{
box = new qkBox;
box.show();
}

qkBox is a QObject.

How can I access this variable from C++ ?
Can I get an array of all QObjects newed inside the script process ?

Thanks.

jpn
16th January 2009, 17:46
Sometimes I feel like docs reading service, but here it goes: Making a QObject-based Class New-able from a Script :)

seneca
16th January 2009, 23:51
Since you are creating the box as global you should be able to get it after script evaluation somewhat as:


QObject* box = engine->globalObject().property("box").toQObject();