Commit 2b0f2c1c8452c16723a15f00117c96c57bb017a8
- Diff rendering mode:
- inline
- side by side
|   | |||
| 225 | 225 | QTest::qSleep(250); | |
| 226 | 226 | //! [23] | |
| 227 | 227 | ||
| 228 | //! [24] | ||
| 229 | QWidget widget; | ||
| 230 | widget.show(); | ||
| 231 | QTest::qWaitForWindowShown(&widget); | ||
| 232 | //! [24] | ||
| 233 | |||
| 228 | 234 | } |
src/testlib/qtestcase.cpp
(10 / 0)
|   | |||
| 731 | 731 | \sa QTest::qSleep() | |
| 732 | 732 | */ | |
| 733 | 733 | ||
| 734 | /*! \fn void QTest::qWaitForWindowManager(QWidget *window) | ||
| 735 | |||
| 736 | Waits until the window is shown in the screen. This is mainly useful for | ||
| 737 | asynchronous systems like X11, where a window will be mapped to screen some | ||
| 738 | time after being asked to show itself on the screen. | ||
| 739 | |||
| 740 | Example: | ||
| 741 | \snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 24 | ||
| 742 | */ | ||
| 743 | |||
| 734 | 744 | /*! | |
| 735 | 745 | \class QTest::QTouchEventSequence | |
| 736 | 746 | \inmodule QtTest |
src/testlib/qtestsystem.h
(18 / 0)
|   | |||
| 52 | 52 | ||
| 53 | 53 | QT_MODULE(Test) | |
| 54 | 54 | ||
| 55 | class QWidget; | ||
| 56 | #ifdef Q_WS_X11 | ||
| 57 | extern void qt_x11_wait_for_window_manager(QWidget *w); | ||
| 58 | #endif | ||
| 59 | |||
| 55 | 60 | namespace QTest | |
| 56 | 61 | { | |
| 57 | 62 | inline static void qWait(int ms) | |
| … | … | ||
| 70 | 70 | QTest::qSleep(10); | |
| 71 | 71 | } while (timer.elapsed() < ms); | |
| 72 | 72 | } | |
| 73 | |||
| 74 | inline static bool qWaitForWindowShown(QWidget *window) | ||
| 75 | { | ||
| 76 | #if defined(Q_WS_X11) | ||
| 77 | qt_x11_wait_for_window_manager(window); | ||
| 78 | #elif defined(Q_WS_QWS) | ||
| 79 | qWait(100); | ||
| 80 | #else | ||
| 81 | qWait(50); | ||
| 82 | #endif | ||
| 83 | return true; | ||
| 84 | } | ||
| 85 | |||
| 73 | 86 | } | |
| 74 | 87 | ||
| 75 | 88 | QT_END_NAMESPACE |

