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. [NOT solved] QtScript and external library (QLibrary)
Forum Updated to NodeBB v4.3 + New Features

[NOT solved] QtScript and external library (QLibrary)

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    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)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JulienMaille
      wrote on last edited by
      #2

      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");@

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        It seems it is really complex to achieve that, however a lib exists:
        http://www.atmark-techno.com/~yashi/libffi.html

        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