Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QScriptable inheritance.
Qt 6.11 is out! See what's new in the release blog

QScriptable inheritance.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michael
    wrote on last edited by
    #1

    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,
    Michael

    1 Reply Last reply
    0
    • M Offline
      M Offline
      michael
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved