Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QJSValue engine() deprecated in Qt5.15

QJSValue engine() deprecated in Qt5.15

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 806 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.
  • D Offline
    D Offline
    Daes
    wrote on last edited by
    #1

    Hello,

    I am using C++ to interpret some callable QJSValue coming from QML as callback functions.
    Currently, i was using the engine() function to add parameters to those function like this:

    QJsValueList args;
    args << callable.engine()->toScriptValue(aValue);
    callcable.call(args);
    

    Now the engine() function is deprecated.
    How can i get the callable engine, as if i use an other engine to create the value, it is not possible to use the call(..) function with it?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kai Nickel
      wrote on last edited by
      #2

      I do not have a real answer for that. But I also use QJSValue callbacks a lot, and I think that this is a very important pattern (which is not so well supported by Qt unfortunately).

      Im my case, the C++ function is always a method of a QObject exposed to QML (either via singleton or it is instantiated from QML). In both cases, you can get the engine via qjsEngine() on that object:

      class App : public QObject {
          Q_OBJECT
          Q_INVOKABLE void doSomethingAsync(QJSValue callback) {
              auto engine = qjsEngine(this);
              ....
          }
      };
      
      1 Reply Last reply
      0
      • D Offline
        D Offline
        Daes
        wrote on last edited by
        #3

        @Kai-Nickel said in QJSValue engine() deprecated in Qt5.15:

        qjsEngine

        Thanks, Kai.
        I didn't know the qjsEngine function.
        I am in the same use case as you, so that should do the trick.

        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