Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtestwheel.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTESTWHEEL_H
5#define QTESTWHEEL_H
6
7#if 0
8// inform syncqt
9#pragma qt_no_master_include
10#endif
11
12#include <QtTest/qttestglobal.h>
13#include <QtTest/qtestassert.h>
14#include <QtTest/qtestsystem.h>
15#include <QtTest/qtestspontaneevent.h>
16#include <QtCore/qpoint.h>
17#include <QtCore/qstring.h>
18#include <QtCore/qpointer.h>
19#include <QtGui/qevent.h>
20#include <QtGui/qwindow.h>
21
22#include <QtCore/QDebug>
23
25
26Q_GUI_EXPORT void qt_handleWheelEvent(QWindow *window, const QPointF &local,
27 const QPointF &global, QPoint pixelDelta,
28 QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase);
29
30namespace QTest
31{
42 [[maybe_unused]] static void wheelEvent(QWindow *window, QPointF pos,
43 QPoint angleDelta, QPoint pixelDelta = QPoint(0, 0),
44 Qt::KeyboardModifiers stateKey = Qt::NoModifier,
46 {
48
49 // pos is in window local coordinates
50 const QSize windowSize = window->geometry().size();
51 if (windowSize.width() <= pos.x() || windowSize.height() <= pos.y()) {
52 qWarning("Mouse event at %d, %d occurs outside target window (%dx%d).",
53 static_cast<int>(pos.x()), static_cast<int>(pos.y()), windowSize.width(), windowSize.height());
54 }
55
56 if (pos.isNull())
57 pos = QPoint(window->width() / 2, window->height() / 2);
58
59 QPointF global = window->mapToGlobal(pos);
60 QPointer<QWindow> w(window);
61
62 if (angleDelta.isNull() && pixelDelta.isNull())
63 qWarning("No angle or pixel delta specified.");
64
65 qt_handleWheelEvent(w, pos, global, pixelDelta, angleDelta, stateKey, phase);
66 qApp->processEvents();
67 }
68}
69
71
72#endif // QTESTWHEEL_H
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
Definition qpoint.h:125
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
static void wheelEvent(QWindow *window, QPointF pos, QPoint angleDelta, QPoint pixelDelta=QPoint(0, 0), Qt::KeyboardModifiers stateKey=Qt::NoModifier, Qt::ScrollPhase phase=Qt::NoScrollPhase)
Definition qtestwheel.h:42
@ NoModifier
ScrollPhase
@ NoScrollPhase
#define qApp
#define qWarning
Definition qlogging.h:166
GLfloat GLfloat GLfloat w
[0]
#define QTEST_ASSERT(cond)
Definition qtestassert.h:11
QT_BEGIN_NAMESPACE Q_GUI_EXPORT void qt_handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase)
Q_GUI_EXPORT void qt_handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase)
aWidget window() -> setWindowTitle("New Window Title")
[2]
QJSValue global