diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 37bb28dec9..1d106f94f3 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -53,6 +53,8 @@ #include #include #include +#include + class SpinBox : public QSpinBox { @@ -343,6 +345,14 @@ tst_QSpinBox::tst_QSpinBox() void tst_QSpinBox::init() { QLocale::setDefault(QLocale(QLocale::C)); + +#if QT_CONFIG(cursor) + // Ensure mouse cursor was not left by previous tests where widgets + // will appear, as it could cause events and interfere with the tests. + const QScreen *screen = QGuiApplication::primaryScreen(); + const QRect availableGeometry = screen->availableGeometry(); + QCursor::setPos(availableGeometry.topLeft()); +#endif } void tst_QSpinBox::setValue_data()