From 6df94b3cfd7eab7222542237a219144615bd434b Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@theqtcompany.com> Date: Thu, 10 Sep 2015 16:08:21 +0200 Subject: [PATCH] Improve runJavaScript documentation Mention that the script will run in the same JavaScript world as scripts that are part of the page. Also link to new scripts API. Change-Id: I4dd80fdd84644b1fa4ce6c63ab07c1dbba855389 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> --- src/webengine/doc/src/webengineview.qdoc | 4 ++++ .../doc/src/qwebenginepage_lgpl.qdoc | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index fd7733d13..b734413ea 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -248,6 +248,10 @@ runJavaScript("document.title", function(result) { console.log(result); }); \endcode + The script will run in the same \e world as other scripts that are + part of the loaded site. + + See WebEngineView::userScripts for an alternative API to inject scripts. */ /*! diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 794cb56d2..173611165 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -596,16 +596,27 @@ /*! \fn void QWebEnginePage::runJavaScript(const QString& scriptSource) - Runs the JavaScript code contained in \a scriptSource. + \overload runJavaScript() + + This convenience function runs the JavaScript code contained in \a scriptSource. */ /*! \fn void QWebEnginePage::runJavaScript(const QString& scriptSource, FunctorOrLambda resultCallback) + Runs the JavaScript code contained in \a scriptSource. + The script will run in the same \e world as other scripts that are part of the loaded site. + When the script has been executed, \a resultCallback is called with the result of the last executed statement. + \a resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a + QVariant parameter. For example: + + \code + page.runJavaScript("document.title", [](const QVariant &v) { qDebug() << v.toString(); }); + \endcode - \note \a resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a QVariant parameter. + See scripts() for an alternative API to inject scripts. */ /*! -- GitLab