diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2022-09-24 09:24:13 +0200 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2022-09-30 22:28:31 +0200 |
commit | e3358e233683575a4b3e5385b1a522a8ddd02f27 (patch) | |
tree | 1420b4fcd1584d3da41425ce8907036b5104ca34 | |
parent | 24d5290133ea593a6e65693ef6154886871739a4 (diff) |
Update documentation of qWaitForWindowActive / qWaitForWindowExposed
Sharpen existing documentation with a focus on use cases and
differences between both methods / overrides in qtestsupport_gui and
qtestsupport_widgets.
Pick-to: 6.4 6.2 5.15
Change-Id: I62b7be437dd43bb0b114af66de51fb4d1f55b671
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/gui/kernel/qtestsupport_gui.cpp | 24 | ||||
-rw-r--r-- | src/widgets/kernel/qtestsupport_widgets.cpp | 29 |
2 files changed, 31 insertions, 22 deletions
diff --git a/src/gui/kernel/qtestsupport_gui.cpp b/src/gui/kernel/qtestsupport_gui.cpp index 9783e873d2..47c69f8b74 100644 --- a/src/gui/kernel/qtestsupport_gui.cpp +++ b/src/gui/kernel/qtestsupport_gui.cpp @@ -18,9 +18,16 @@ QT_BEGIN_NAMESPACE /*! \since 5.0 - Waits for \a timeout milliseconds or until the \a window is active. + Returns \c true, if \a window is active within \a timeout milliseconds. Otherwise returns \c false. - Returns \c true if \c window is active within \a timeout milliseconds, otherwise returns \c false. + The method is useful in tests that call QWindow::show() and rely on the window actually being + active (i.e. being visible and having focus) before proceeding. + + \note The method will time out and return \c false if another window prevents \a window from + becoming active. + + \note Since focus is an exclusive property, \a window may loose its focus to another window at + any time - even after the method has returned \c true. \sa qWaitForWindowExposed(), QWindow::isActive() */ @@ -40,15 +47,14 @@ Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout) /*! \since 5.0 - Waits for \a timeout milliseconds or until the \a window is exposed. - Returns \c true if \c window is exposed within \a timeout milliseconds, otherwise returns \c false. + Returns \c true, if \a window is exposed within \a timeout milliseconds. Otherwise returns \c false. - This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some - time after being asked to show itself on the screen. + The method is useful in tests that call QWindow::show() and rely on the window actually being + being visible before proceeding. - Note that a window that is mapped to screen may still not be considered exposed if the window client - area is completely covered by other windows, or if the window is otherwise not visible. This function - will then time out when waiting for such a window. + \note A window mapped to screen may still not be considered exposed, if the window client area is + not visible, e.g. because it is completely covered by other windows. + In such cases, the method will time out and return \c false. \sa qWaitForWindowActive(), QWindow::isExposed() */ diff --git a/src/widgets/kernel/qtestsupport_widgets.cpp b/src/widgets/kernel/qtestsupport_widgets.cpp index 4aee48d00d..1141fcea0a 100644 --- a/src/widgets/kernel/qtestsupport_widgets.cpp +++ b/src/widgets/kernel/qtestsupport_widgets.cpp @@ -32,9 +32,16 @@ static bool qWaitForWidgetWindow(FunctorWindowGetter windowGetter, FunctorPredic /*! \since 5.0 - Waits for \a timeout milliseconds or until the \a widget's window is active. + Returns \c true if \a widget is active within \a timeout milliseconds. Otherwise returns \c false. - Returns \c true if \c widget's window is active within \a timeout milliseconds, otherwise returns \c false. + The method is useful in tests that call QWidget::show() and rely on the widget actually being + active (i.e. being visible and having focus) before proceeding. + + \note The method will time out and return \c false if another window prevents \a widget from + becoming active. + + \note Since focus is an exclusive property, \a widget may loose its focus to another window at + any time - even after the method has returned \c true. \sa qWaitForWindowExposed(), QWidget::isActiveWindow() */ @@ -56,20 +63,16 @@ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout) /*! \since 5.0 - Waits for \a timeout milliseconds or until the \a widget's window is exposed. - Returns \c true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns \c false. - - This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some - time after being asked to show itself on the screen. + Returns \c true if \a widget is exposed within \a timeout milliseconds. Otherwise returns \c false. - Note that a window that is mapped to screen may still not be considered exposed if the window client - area is completely covered by other windows, or if the window is otherwise not visible. This function - will then time out when waiting for such a window. + The method is useful in tests that call QWidget::show() and rely on the widget actually being + being visible before proceeding. - A specific configuration where this happens is when using QGLWidget as a viewport widget on macOS: - The viewport widget gets the expose event, not the parent widget. + \note A window mapped to screen may still not be considered exposed, if the window client area is + not visible, e.g. because it is completely covered by other windows. + In such cases, the method will time out and return \c false. - \sa qWaitForWindowActive() + \sa qWaitForWindowActive(), QWidget::isVisible(), QWindow::isExposed() */ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout) { |