[NOT solved] QtScript and external library (QLibrary)

  • Dear Qt users,
    I recently discovered how powerful is the "QtScript":http://qt-project.org/doc/qt-4.8/qtscript.html module but I'm a bit surprised by how few answers I can find in Google when typing any query related to this module. It looks like only a few people take advantage of it.

    I'm using it in combination with "qtscriptgenerator":http://gitorious.org/qt-labs/qtscriptgenerator and that's rally neat: the user is able to creates it's own GUI, connect it's own function to existing signals, etc.

    Now I'm wondering if there is a simple way to let the user write a plugin and expose it to QtScript. I was trying to interface "QLibrary":http://qt-project.org/doc/qt-4.8/qlibrary.html with QtScript but I'm not sure it does make a sense:
    it seems I won't be able to use any function that use custom types/classes, same with function that pass arguments as reference, etc.

    What would you suggest? Telling the user to write a Qt plugin is a bit painful (he will have to use the same qt and compiler version for instance)

  • I'm considering implementing a simpler solution than described.
    However I still have the following problem: using the QLibrary implies using declaring a typedef like in this example: @typedef int (Function)(int, int);
    Function avg = (Function) library->resolve("avg");
    return avg(5, 8);@
    In my case I would like to wrap that code in a function that take the prototype of the function as a QString, the argument as a void
    * and call @wrapper("int avg(int, int)", 5, 8)@

    How can I adapt the typedef and the resolve call to dynamically adapt to the given QString? Is this even possible?
    I know the "QAxBase":http://qt-project.org/doc/qt-4.8/qaxbase.html#dynamicCall allows calling an activeX this way: @activeX->dynamicCall("Navigate(const QString&)", "qt.nokia.com");@

  • It seems it is really complex to achieve that, however a lib exists:

Log in to reply

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