File indexing completed on 2025-09-16 09:06:18
0001
0002
0003
0004 #ifndef QTESTWHEEL_H
0005 #define QTESTWHEEL_H
0006
0007 #if 0
0008
0009 #pragma qt_no_master_include
0010 #endif
0011
0012 #include <QtTest/qttestglobal.h>
0013 #include <QtTest/qtestassert.h>
0014 #include <QtTest/qtestsystem.h>
0015 #include <QtTest/qtestspontaneevent.h>
0016 #include <QtCore/qpoint.h>
0017 #include <QtCore/qstring.h>
0018 #include <QtCore/qpointer.h>
0019 #include <QtGui/qevent.h>
0020 #include <QtGui/qwindow.h>
0021
0022 QT_BEGIN_NAMESPACE
0023
0024 Q_GUI_EXPORT void qt_handleWheelEvent(QWindow *window, const QPointF &local,
0025 const QPointF &global, QPoint pixelDelta,
0026 QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase);
0027
0028 namespace QTest
0029 {
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 [[maybe_unused]] static void wheelEvent(QWindow *window, QPointF pos,
0041 QPoint angleDelta, QPoint pixelDelta = QPoint(0, 0),
0042 Qt::KeyboardModifiers stateKey = Qt::NoModifier,
0043 Qt::ScrollPhase phase = Qt::NoScrollPhase)
0044 {
0045 QTEST_ASSERT(window);
0046
0047
0048 const QSize windowSize = window->geometry().size();
0049 if (windowSize.width() <= pos.x() || windowSize.height() <= pos.y()) {
0050 qWarning("Mouse event at %d, %d occurs outside target window (%dx%d).",
0051 static_cast<int>(pos.x()), static_cast<int>(pos.y()), windowSize.width(), windowSize.height());
0052 }
0053
0054 if (pos.isNull())
0055 pos = QPoint(window->width() / 2, window->height() / 2);
0056
0057 QPointF global = window->mapToGlobal(pos);
0058 QPointer<QWindow> w(window);
0059
0060 if (angleDelta.isNull() && pixelDelta.isNull())
0061 qWarning("No angle or pixel delta specified.");
0062
0063 qt_handleWheelEvent(w, pos, global, pixelDelta, angleDelta, stateKey, phase);
0064 qApp->processEvents();
0065 }
0066 }
0067
0068 QT_END_NAMESPACE
0069
0070 #endif