diff options
| author | Kaloyan Chehlarski <kaloyan.chehlarski@qt.io> | 2025-11-04 10:32:53 +0100 |
|---|---|---|
| committer | Kaloyan Chehlarski <kaloyan.chehlarski@qt.io> | 2025-11-26 20:58:00 +0100 |
| commit | 578d9b0c2940a64b431b30460fb6654dbc290106 (patch) | |
| tree | 18853d6158b3074ce570b8bb5a497e338be11494 /src/webenginequick/api/qquickwebengineview.cpp | |
| parent | 5f45d1ecfbd2747747653d67397f8d8191dbafb7 (diff) | |
Quick: Add runJavaScript overload with std::function callback
This is to be used in QWebView, where the WebEngine backend is
based on our Quick API. With the addition of a C++ WebView API,
we need a way to call C++ callbacks, and the JavaScript-based callback
mechanism that's currently there is insufficient.
We can't expose an std::function parameter to QML, so this overload
is there for internal use only.
Change-Id: I22b17c2d2ba554078d0e1e39110147399e93102b
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/webenginequick/api/qquickwebengineview.cpp')
| -rw-r--r-- | src/webenginequick/api/qquickwebengineview.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp index d06185380..f0d972448 100644 --- a/src/webenginequick/api/qquickwebengineview.cpp +++ b/src/webenginequick/api/qquickwebengineview.cpp @@ -1504,6 +1504,12 @@ bool QQuickWebEngineView::canGoForward() const return d->adapter->canGoForward(); } +void QQuickWebEngineView::runJavaScript(const QString &script, const std::function<void(const QVariant &)> &resultCallback) +{ + Q_D(QQuickWebEngineView); + d->runJavaScript(script, QWebEngineScript::MainWorld, WebContentsAdapter::kUseMainFrameId, resultCallback); +} + void QQuickWebEngineView::runJavaScript(const QString &script, const QJSValue &callback) { runJavaScript(script, QWebEngineScript::MainWorld, callback); |
