QScriptable inheritance.

  • Hi all,

    I'm trying to make some of my classes scriptable. I have classes A, B, C, and A<-B<-C.
    I declared JS prototypes for them in classes JA, JB, JC, and JA<-JB<-JC. I
    called setDefaultPrototype() for every J* class.

    Now I call engine->globalObject().setProperty("ptr", engine->toScriptValue<const C *>(CPtr));

    I expect that I can access from JS all the properties of JA and JB using ptr. But actually I can access
    JC properties only.

    I don't understand what I'm doing wrong. Does anybody know how to inherit JS prototype classes?

    Thank you,

  • It looks like the problem is qscriptvalue_cast() function. It does not understand that class C is also a class A since C inherits to A. And when I call

    A *p = qscriptvalue_cast<A >(thisObject());

    where thisObject() is actually an object of class C, qscriptvalue_cast() returns 0.

    Still trying to fix that somehow, but with no any luck so far...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.