[Qt-interest] boost types in methods called from QtScript

RZ rz at univie.ac.at
Wed Feb 17 20:48:14 CET 2010


Hello all,

I managed to get my C++ (QObject derived) class invokable from QtScript. 
So I can do in QtScript:

var myClass = new MyClass();

Unfortunately this C++ base class uses boost::uint32_t, boost::uint16_t, 
... (and then typedef boost::uint32_t uint32, ..). So a method inside my 
class is:

SetStartParameters(uint32 a, uint16 b)

I can do

myClass.SetStartParameters(1, 2);

but whatever I try if I want to use var's instead like

var i = 2;
myClass.SetStartParameters(1, i);

I always get a "TypeError" (because i is no uint16); interestingly it 
works if I construct an overloaded method using Qt's types

SetStartParameters(quint32 a, quint16 b);

I tried things like Q_DECLARE_METATYPE(uint32), 
qRegisterMetaType<uint32>("uint32"), qScriptRegisterMetaType (where I 
don't know if I passed all parameters correctly).

Can anybody help what to do to get uint32 to work?

Thx,

RZ




More information about the Qt-interest-old mailing list