Setting QObject ownship for QWebFrame javascript

  • I have a QObject that exists in a QWebFrame javascript environment through the addToJavaScriptWindowObject interface. This QObject has Q_INVOKABLE methods that return more QObject pointers (like a factory) that are used within javascript. Qt automatically turns these QObject pointer into objects that can be invoked in the calling javascript enviornment.

    The issue is, I want to have javascript assume ownership of this QObject. The current behavior is that the C++ environment retains ownership.

    I've dealt with QScriptEngine directly in the past where the QObject factory object holds a pointer to the QScriptEngine object and creates new objects using QScriptEngine::newQObject with a QScriptEngine::ScriptOwnership argument. This works perfectly. But for the QWebFrame javascript engine, the engine is buried inside of the QWebFrame and inaccessible.

    How can I return QObject's to a QWebFrame javascript environment and have javascript assume ownship of that object?

Log in to reply

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