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. Dynamically add functions to C++ objects exposed to JS
Forum Updated to NodeBB v4.3 + New Features

Dynamically add functions to C++ objects exposed to JS

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

    Hello,

    I have an ID and a type representing some Object O of type T in my application. I do not have direct access to this object. I only have its ID. I however want to expose this object to JS. I cannot create "normal" QObject wrappers for each of the classes I need to exposed with Q_INVOKABLE methods because:

    available methods are numerous and may be changing a lot in the future; So, if I need to write QObject wrappers, I will spend all my time (and maybe more) maintaining them;

    Objects are potentially heavy and copying them here and there is costly.

    Instead, I can retrieve the list of prototypes attached to each classes I need to expose to JS. So, what I want to do:

    From ID, retrieve the list of functions prototypes attached to this object;

    Dynamically attach these functions to a QObject (or similar); each function should call some global function.

    Pass this object to the JS engine and use it.

    At that point, I would be ok.

    So:
    Is it at least a good idea? If yes, how can I dynamically attach methods to newly created objects and pass them to the JS engine?

    Thanks for any help.

    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