Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Exposing third-party API to QtScript

    Brainstorm
    1
    1
    1699
    Loading More Posts
    • 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
      hipersayan_x last edited by

      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 Reply Quote 0
      • First post
        Last post