aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2023-12-20 17:13:35 +0800
committerMitch Curtis <mitch.curtis@qt.io>2024-01-15 20:36:14 +0800
commitc9b32cf8e82a09884501991eac25f3a5835f118f (patch)
treef956fdefb18a91e3ca17d6d9a764cb6bc651a255 /src/qmltest
parentf233a5ff9d04daf3ba792cc196da7e5f190b415c (diff)
Doc: explain how to ensure the TestCase's window is active
Pick-to: 6.5 6.6 6.7 Change-Id: I0d2e8a8ffdabba9cd6f0aee7dad8e79728c0261b Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/TestCase.qml9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/qmltest/TestCase.qml b/src/qmltest/TestCase.qml
index 638372a42a..9b47254bdb 100644
--- a/src/qmltest/TestCase.qml
+++ b/src/qmltest/TestCase.qml
@@ -166,6 +166,15 @@ import "testlogger.js" as TestLogger
and mouseMove() methods can be used to simulate mouse events in a
similar fashion.
+ If your test creates other windows, it's possible that those windows
+ become active, stealing the focus from the TestCase's window. To ensure
+ that the TestCase's window is active, use the following code:
+
+ \code
+ testCase.Window.window.requestActivate()
+ tryCompare(testCase.Window.window, "active", true)
+ \endcode
+
\b{Note:} keyboard and mouse events can only be delivered once the
main window has been shown. Attempts to deliver events before then
will fail. Use the \l when and windowShown properties to track