summaryrefslogtreecommitdiff
path: root/examples/webenginewidgets/printme/doc/src
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2021-08-27 13:24:42 +0200
committerSzabolcs David <davidsz@inf.u-szeged.hu>2021-08-30 18:28:22 +0200
commite3679c1a8316b70fb6b8a0f85fdd06443de8b409 (patch)
treecc08a0ccfa5f7c5b5cb0e0062401359ced7f6865 /examples/webenginewidgets/printme/doc/src
parent4fd6eeca81b7b0758a34f3f604f0fb3dd92f7de4 (diff)
downloadqtwebengine-e3679c1a8316b70fb6b8a0f85fdd06443de8b409.tar.gz
Fix crash in PrintMe example
Connecting the same lambda slot multiple times to QWebEngineView::printFinished causes crash. Fix this by a minor refactoration and adjust documentation. Pick-to: 6.2 Task-number: QTBUG-95339 Change-Id: I03b6a1ff6244c80073248182a905d8d664fdd326 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'examples/webenginewidgets/printme/doc/src')
-rw-r--r--examples/webenginewidgets/printme/doc/src/printme.qdoc21
1 files changed, 14 insertions, 7 deletions
diff --git a/examples/webenginewidgets/printme/doc/src/printme.qdoc b/examples/webenginewidgets/printme/doc/src/printme.qdoc
index 1ba37d0c3..f17fae1a8 100644
--- a/examples/webenginewidgets/printme/doc/src/printme.qdoc
+++ b/examples/webenginewidgets/printme/doc/src/printme.qdoc
@@ -66,8 +66,8 @@
\section1 Print Handler
- In the \c{PrintHandler} function, we first implement \c{printPreview()},
- where we instantiate \l{QPrinter} together with \l{QPrintPreviewDialog}.
+ In the \c{PrintHandler} class, we first implement \c{printPreview()},
+ where we instantiate \l{QPrintPreviewDialog}.
We need the \l{QPrintPreviewDialog::paintRequested} handle to generate a
set of preview pages.
@@ -77,16 +77,23 @@
Now we can implement the \c{PrintHandler::printDocument()} slot, which is
called in response to the \l{QPrintPreviewDialog::paintRequested} signal.
+ To do actual painting on a printer, we call the \l QWebEngineView::print()
+ function. Because this call is asynchronous, we need to use
+ a local event loop. We begin the local event loop by calling
+ \l{QEventLoop::exec()}.
\quotefromfile webenginewidgets/printme/printhandler.cpp
\skipto PrintHandler::printDocument(
\printuntil /^\}/
- To do actual painting on a printer, we call the \l QWebEngineView::print()
- function. Because this call blocks the main event loop, we need to create
- a local one. We begin the local event loop by calling
- \l{QEventLoop::exec()}. When the local event loop terminates,
- we check for \c{result} and report any errors that occurred.
+ To get notified about the result of printing job, we implement
+ \c{PrintHandler::printFinished()} slot as handler of
+ \l QWebEngineView::printFinished() signal. We check for \c{success} and
+ report any errors that occurred.
+
+ \quotefromfile webenginewidgets/printme/printhandler.cpp
+ \skipto PrintHandler::printFinished(
+ \printuntil /^\}/
The last function we implement, \c{PrintHandler::print()}, is trivial,
because it simply opens \l{QPrintDialog} and calls the previously