diff options
| author | Kaloyan Chehlarski <kaloyan.chehlarski@qt.io> | 2025-11-05 16:25:46 +0100 |
|---|---|---|
| committer | Michal Klocek <michal.klocek@qt.io> | 2025-12-01 17:39:09 +0100 |
| commit | 388251ce343c617fc7a383485e9417a5306adb14 (patch) | |
| tree | d658d527356e3ebea469c59ef15af5dc05d3a8e8 /src/webview/qwebview.h | |
| parent | c0b0855c702854c65ecdfe39a97d3f969b8780ad (diff) | |
Add runJavascript() to C++ API
The API follows what we have in WebEngine, with an optional
std::function callback. No world ID argument is provided, however;
most of the backends don't support the concept.
The new function is not exposed to QML, since we cannot expose
std::function arguments. Instead, the existing QML API is kept,
and calls to it simply redirect to the C++ implementation.
Also removes runJavaScriptPrivate() from QWebView, and its related
implementation details in the plugins.
Task-number: QTBUG-131837
Change-Id: Idc1e492916e17caa3f061c0b2738b3c735837cf8
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/webview/qwebview.h')
| -rw-r--r-- | src/webview/qwebview.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/webview/qwebview.h b/src/webview/qwebview.h index 94681b1..1e3a160 100644 --- a/src/webview/qwebview.h +++ b/src/webview/qwebview.h @@ -61,21 +61,18 @@ public: Q_INVOKABLE void deleteCookie(const QString &domain, const QString &name); Q_INVOKABLE void deleteAllCookies(); - // FIXME runjavascript + void runJavaScript(const QString &script, + const std::function<void(const QVariant &)> &resultCallback = {}); Q_SIGNALS: void titleChanged(QString title); void urlChanged(QUrl url); void loadingChanged(const QWebViewLoadRequest &loadRequest); void loadProgressChanged(int loadProgress); - void javaScriptResult(int id, const QVariant &result); void httpUserAgentChanged(QString userAgent); void cookieAdded(const QString &domain, const QString &name); void cookieRemoved(const QString &domain, const QString &name); -protected: - void runJavaScriptPrivate(const QString &script, int callbackId); - private: Q_DISABLE_COPY(QWebView) |
