Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Exposing third-party API to QtScript
QtWS25 Last Chance

Exposing third-party API to QtScript

Scheduled Pinned Locked Moved Brainstorm
1 Posts 1 Posters 1.8k Views
  • 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.
  • H Offline
    H Offline
    hipersayan_x
    wrote on last edited by
    #1

    Hello, Im working in a proyect where some plugin capabilities are need, because I need this plugins to be multiplataform, then I desired to try out making this with QtScript.
    One of the API's I want to expose is OpenSceneGraph, then my plugins developers, can render advanced 3D scenes without worry about plataform issues.
    But I stuck because can't figure out how to convert from a OSG type to a QtScriptValue and viceversa.
    For example, I want to expose "osgDB::readNodeFile()":http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01557.html#177e1656d3766fcab9e38c7681fb94b3, It's form is:

    @osg::Node* osgDB::readNodeFile(const std::string &filename;, const ReaderWriter::Options *options)@

    Then create the wrapper funcion as show in:

    http://doc.qt.nokia.com/latest/qscriptengine.html#newFunction

    @// Create the wrapper funtion.
    static QScriptValue osgDB_readNodeFile(QScriptContext *context, QScriptEngine *engine)
    {
    // Obtains the arguments from QtScript.
    QScriptValue filename = context->argument(0):
    QScriptValue options = context->argument(1):

    // Here is my first question, ¿How I can convert from QScriptValue to a OSG type?
    osg::Node *retval = osgDB::readNodeFile(filename.toString().constData(), optionsretval.toOSG());
    
    //And second, ¿How I can convert from a OSG type to QScriptValue?
    return toQtScript(retval);
    

    }@

    Of course, a second (and more easy) option is to distribute the plugins as source code, and making it binary by compiling at install time, but I think the first option is more correct.
    Some clue about this problem will be appreciated.

    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