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. Type casting in QtScript.
Forum Updated to NodeBB v4.3 + New Features

Type casting in QtScript.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.2k 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 8 Apr 2011, 15:41 last edited by
    #1

    I have a class hierarchy

    @
    class A
    {

    public:

    QList<A*> list()
    {
         return _list;
    }
    

    protected:

    QList<A*> _list;

    };

    class B : public A
    {
    B()
    {
    _list.push_back(this);
    }
    };
    @

    Both classes are not QObject descendants.

    I expose both classes to QtScript using QScriptable classes and QScriptEngine::setDefaultPrototype() method. Method list() is exposed to QtScript.

    When I call list() from JavaScript I get a collection of pointers to class A, but among them I have pointers to class B. How I can cast those pointers to B* in JavaScript? Or maybe it is possible to change A* prototype to B* prototype? Maybe it is possible to write some function to do that in C++.

    Does somebody have any ideas how to solve the problem?

    Thanks,
    MIchael

    [EDIT: code formatting, please use @-tags, Volker]

    1 Reply Last reply
    0

    1/1

    8 Apr 2011, 15:41

    • Login

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