summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
diff options
context:
space:
mode:
authorMoss Heim <moss.heim@qt.io>2024-04-04 13:39:18 +0200
committerMoss Heim <moss.heim@qt.io>2024-05-02 10:20:58 +0200
commit07734ab077fe93b3db389ff24a05b9af4fb65f6b (patch)
treec6334ce191a7cee7f5054a57d86569cf1bf2edd1 /examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
parentc899da78dc658691f02a431f9105fc2f84c737cd (diff)
Update simplebrowser example to use onbeforeunloadHEADdev
Previously simplebrowser did not make use of the RequestClose webaction to trigger the beforeunload JavaScript event. This meant that closing a tab would not trigger this event or a confirmation dialog, but reloading a tab would. This commit hooks up the appropriate signal in the example code. Fixes: QTBUG-124004 Change-Id: I0a4ce242b6c2f89583504841d817285610be0bd0 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc')
-rw-r--r--examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
index dd7a8b998..211535204 100644
--- a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
+++ b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
@@ -103,6 +103,25 @@
\skipto TabWidget::setupView
\printuntil /^\}/
+ \section1 Closing Tabs
+
+ When the user closes a tab, we first trigger the \l {QWebEnginePage::}{RequestClose} web action
+ on the corresponding \c WebView:
+
+ \quotefromfile webenginewidgets/simplebrowser/tabwidget.cpp
+ \skipto QTabBar::tabCloseRequested
+ \printuntil }
+
+ This allows any JavaScript \c beforeunload event listeners to fire, which may
+ prompt the user with a dialog to confirm that they want to close the page.
+ In this case, the user can reject the close request and leave the tab open,
+ otherwise the \l {QWebEnginePage::}{windowCloseRequested} signal is emitted and we close the
+ tab:
+
+ \quotefromfile webenginewidgets/simplebrowser/tabwidget.cpp
+ \skipto QWebEnginePage::windowCloseRequested
+ \printuntil }
+
\section1 Implementing WebView Functionality
The \c WebView is derived from QWebEngineView to support the following