summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp1709
1 files changed, 608 insertions, 1101 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 5b7bf73dbf..d8c11d72a6 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1,49 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qevent.h"
+
#include "qcursor.h"
#include "private/qguiapplication_p.h"
#include "private/qinputdevice_p.h"
#include "private/qpointingdevice_p.h"
#include "qpa/qplatformintegration.h"
#include "private/qevent_p.h"
+#include "private/qeventpoint_p.h"
+
#include "qfile.h"
#include "qhashfunctions.h"
#include "qmetaobject.h"
@@ -51,19 +18,41 @@
#include "qevent_p.h"
#include "qmath.h"
#include "qloggingcategory.h"
+#include "qpointer.h"
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>
#include <private/qdnd_p.h>
#endif
+#if QT_CONFIG(shortcut)
+#include <private/qshortcut_p.h>
+#endif
+
#include <private/qdebug_p.h>
+#define Q_IMPL_POINTER_EVENT(Class) \
+ Class::Class(const Class &) = default; \
+ Class::~Class() = default; \
+ Class* Class::clone() const \
+ { \
+ auto c = new Class(*this); \
+ for (auto &point : c->m_points) \
+ QMutableEventPoint::detach(point); \
+ QEvent *e = c; \
+ /* check that covariant return is safe to add */ \
+ Q_ASSERT(reinterpret_cast<quintptr>(c) == reinterpret_cast<quintptr>(e)); \
+ return c; \
+ }
+
+
+
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(lcPointerGrab, "qt.pointer.grab")
-Q_LOGGING_CATEGORY(lcPointerVel, "qt.pointer.velocity")
-Q_LOGGING_CATEGORY(lcEPDetach, "qt.pointer.eventpoint.detach")
+static_assert(sizeof(QMutableTouchEvent) == sizeof(QTouchEvent));
+static_assert(sizeof(QMutableSinglePointEvent) == sizeof(QSinglePointEvent));
+static_assert(sizeof(QMouseEvent) == sizeof(QSinglePointEvent));
+static_assert(sizeof(QVector2D) == sizeof(quint64));
/*!
\class QEnterEvent
@@ -85,59 +74,63 @@ Q_LOGGING_CATEGORY(lcEPDetach, "qt.pointer.eventpoint.detach")
window, and screen or desktop, respectively.
*/
QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, const QPointingDevice *device)
- : QSinglePointEvent(QEvent::Enter, device, localPos, scenePos, globalPos)
+ : QSinglePointEvent(QEvent::Enter, device, localPos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier)
{
}
-/*!
- \internal
-*/
-QEnterEvent::~QEnterEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QEnterEvent)
/*!
\fn QPoint QEnterEvent::globalPos() const
+ \deprecated [6.0] Use globalPosition() instead.
Returns the global position of the mouse cursor \e{at the time of the event}.
*/
/*!
\fn int QEnterEvent::globalX() const
+ \deprecated [6.0] Use globalPosition().x() instead.
Returns the global position on the X-axis of the mouse cursor \e{at the time of the event}.
*/
/*!
\fn int QEnterEvent::globalY() const
+ \deprecated [6.0] Use globalPosition().y() instead.
Returns the global position on the Y-axis of the mouse cursor \e{at the time of the event}.
*/
/*!
\fn QPointF QEnterEvent::localPos() const
+ \deprecated [6.0] Use position() instead.
Returns the mouse cursor's position relative to the receiving widget.
*/
/*!
\fn QPoint QEnterEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the mouse cursor relative to the receiving widget.
*/
/*!
\fn QPointF QEnterEvent::screenPos() const
+ \deprecated [6.0] Use globalPosition() instead.
Returns the position of the mouse cursor relative to the receiving screen.
*/
/*!
\fn QPointF QEnterEvent::windowPos() const
+ \deprecated [6.0] Use scenePosition() instead.
Returns the position of the mouse cursor relative to the receiving window.
*/
/*!
\fn int QEnterEvent::x() const
+ \deprecated [6.0] Use position().x() instead.
Returns the x position of the mouse cursor relative to the receiving widget.
*/
/*!
\fn int QEnterEvent::y() const
+ \deprecated [6.0] Use position().y() instead.
Returns the y position of the mouse cursor relative to the receiving widget.
*/
@@ -155,22 +148,24 @@ QEnterEvent::~QEnterEvent()
\internal
*/
QInputEvent::QInputEvent(Type type, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
- : QEvent(type, QEvent::InputEventTag{}), m_dev(dev), m_modState(modifiers)
+ : QEvent(type, QEvent::InputEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
{}
/*!
\internal
*/
QInputEvent::QInputEvent(QEvent::Type type, QEvent::PointerEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
- : QEvent(type, QEvent::PointerEventTag{}), m_dev(dev), m_modState(modifiers)
+ : QEvent(type, QEvent::PointerEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
{}
/*!
\internal
*/
-QInputEvent::~QInputEvent()
-{
-}
+QInputEvent::QInputEvent(QEvent::Type type, QEvent::SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
+ : QEvent(type, QEvent::SinglePointEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
+{}
+
+Q_IMPL_EVENT_COMMON(QInputEvent)
/*!
\fn QInputDevice *QInputEvent::device() const
@@ -211,14 +206,14 @@ QInputEvent::~QInputEvent()
*/
/*!
- \fn ulong QInputEvent::timestamp() const
+ \fn quint64 QInputEvent::timestamp() const
Returns the window system's timestamp for this event.
It will normally be in milliseconds since some arbitrary point
in time, such as the time when the system was started.
*/
-/*! \fn void QInputEvent::setTimestamp(ulong atimestamp)
+/*! \fn void QInputEvent::setTimestamp(quint64 atimestamp)
\internal
@@ -226,347 +221,6 @@ QInputEvent::~QInputEvent()
*/
/*!
- \internal
- Constructs an invalid event point with the given \a id and the \a device
- from which it originated.
-
- This acts as a default constructor in usages like QMap<int, QEventPoint>,
- as in qgraphicsscene_p.h.
-*/
-QEventPoint::QEventPoint(int id, const QPointingDevice *device)
- : d(new QEventPointPrivate(id, device)) {}
-
-/*!
- Constructs an event point with the given \a pointId, \a state,
- \a scenePosition and \a globalPosition.
-*/
-QEventPoint::QEventPoint(int pointId, State state, const QPointF &scenePosition, const QPointF &globalPosition)
- : d(new QEventPointPrivate(pointId, state, scenePosition, globalPosition)) {}
-
-QEventPoint::QEventPoint(const QEventPoint &other)
- : d(other.d)
-{
- d->refCount++;
-}
-
-QEventPoint &QEventPoint::operator=(const QEventPoint &other)
-{
- other.d->refCount++;
- if (!(--d->refCount))
- delete d;
- d = other.d;
- return *this;
-}
-
-QEventPoint::~QEventPoint()
-{
- if (!(--d->refCount))
- delete d;
-}
-
-QPointF QEventPoint::position() const
-{ return d->pos; }
-
-QPointF QEventPoint::pressPosition() const
-{ return d->globalPressPos - d->globalPos + d->pos; }
-
-QPointF QEventPoint::grabPosition() const
-{ return d->globalGrabPos - d->globalPos + d->pos; }
-
-QPointF QEventPoint::lastPosition() const
-{ return d->globalLastPos - d->globalPos + d->pos; }
-
-QPointF QEventPoint::scenePosition() const
-{ return d->scenePos; }
-
-QPointF QEventPoint::scenePressPosition() const
-{ return d->globalPressPos - d->globalPos + d->scenePos; }
-
-QPointF QEventPoint::sceneGrabPosition() const
-{ return d->globalGrabPos - d->globalPos + d->scenePos; }
-
-QPointF QEventPoint::sceneLastPosition() const
-{ return d->globalLastPos - d->globalPos + d->scenePos; }
-
-QPointF QEventPoint::globalPosition() const
-{ return d->globalPos; }
-
-QPointF QEventPoint::globalPressPosition() const
-{ return d->globalPressPos; }
-
-QPointF QEventPoint::globalGrabPosition() const
-{ return d->globalGrabPos; }
-
-QPointF QEventPoint::globalLastPosition() const
-{ return d->globalLastPos; }
-
-QVector2D QEventPoint::velocity() const
-{ return d->velocity; }
-
-QEventPoint::State QEventPoint::state() const
-{ return d->state; }
-
-const QPointingDevice *QEventPoint::device() const
-{ return d->device; }
-
-int QEventPoint::id() const
-{ return d->pointId; }
-
-QPointingDeviceUniqueId QEventPoint::uniqueId() const
-{ return d->uniqueId; }
-
-ulong QEventPoint::timestamp() const
-{ return d->timestamp; }
-
-ulong QEventPoint::pressTimestamp() const
-{ return d->pressTimestamp; }
-
-qreal QEventPoint::timeHeld() const
-{ return (d->timestamp - d->pressTimestamp) / qreal(1000); }
-
-qreal QEventPoint::pressure() const
-{ return d->pressure; }
-
-qreal QEventPoint::rotation() const
-{ return d->rotation; }
-
-QSizeF QEventPoint::ellipseDiameters() const
-{ return d->ellipseDiameters; }
-
-bool QEventPoint::isAccepted() const
-{ return d->accept; }
-
-/*!
- Returns the time from the previous QPointerEvent that contained this point.
-
- \sa globalLastPosition()
-*/
-ulong QEventPoint::lastTimestamp() const
-{ return d->lastTimestamp; }
-
-/*!
- Sets the accepted state of the point.
-
- In widget-based applications, this function is not used so far, because
- it's only meaningful for a widget to accept or reject a complete QInputEvent.
-
- In Qt Quick however, it's normal for an Item or Event Handler to accept
- only the individual points in a QTouchEvent that are actually participating
- in a gesture, while other points can be delivered to other items or
- handlers. For the sake of consistency, that applies to any QPointerEvent;
- and delivery is done only when all points in a QPointerEvent have been
- accepted.
-
- \sa QEvent::setAccepted()
-*/
-void QEventPoint::setAccepted(bool accepted)
-{
- d->accept = accepted;
-}
-
-/*!
- \obsolete
- Deprecated since Qt 6.0. Use globalPosition() instead.
-
- Returns the normalized position of this point.
-
- The coordinates are normalized to QInputDevice::availableVirtualGeometry(),
- i.e. (0, 0) is the top-left corner and (1, 1) is the bottom-right corner.
-
- \sa startNormalizedPos(), lastNormalizedPos(), pos()
-*/
-QPointF QEventPoint::normalizedPos() const
-{
- auto geom = d->device->availableVirtualGeometry();
- if (geom.isNull())
- return QPointF();
- return (globalPosition() - geom.topLeft()) / geom.width();
-}
-
-/*!
- \obsolete
- Deprecated since Qt 6.0. Use globalPressPosition() instead.
-
- Returns the normalized press position of this point.
-*/
-QPointF QEventPoint::startNormalizedPos() const
-{
- auto geom = d->device->availableVirtualGeometry();
- if (geom.isNull())
- return QPointF();
- return (globalPressPosition() - geom.topLeft()) / geom.width();
-}
-
-/*!
- \obsolete
- Deprecated since Qt 6.0. Use globalLastPosition() instead.
-
- Returns the normalized position of this point from the previous press or
- move event.
-
- The coordinates are normalized to QInputDevice::availableVirtualGeometry(),
- i.e. (0, 0) is the top-left corner and (1, 1) is the bottom-right corner.
-
- \sa normalizedPos(), startNormalizedPos()
-*/
-QPointF QEventPoint::lastNormalizedPos() const
-{
- auto geom = d->device->availableVirtualGeometry();
- if (geom.isNull())
- return QPointF();
- return (globalLastPosition() - geom.topLeft()) / geom.width();
-}
-
-
-/*! \internal
- This class is explicitly shared, which means if you construct an event and
- then the point(s) that it holds are modified before the event is delivered,
- the event will be seen to hold the modified points. The workaround is that
- any code which modifies an eventpoint that could already be included in an
- event, or code that wants to save an eventpoint for later, has
- responsibility to detach before calling any setters, so as to hold and
- modify an independent copy. (The independent copy can then be used in a
- subsequent event.) If detaching is unnecessary, because refCount shows that
- there is only one QEventPoint referring to the QEventPointPrivate instance,
- this function does nothing.
-*/
-void QMutableEventPoint::detach()
-{
- if (d->refCount == 1)
- return; // no need: there is only one QEventPoint using it
- qCDebug(lcEPDetach) << "detaching: refCount" << d->refCount << this;
- d = new QEventPointPrivate(*d);
- d->refCount = 1;
-}
-
-/*! \internal
- Update current state from the given \a other point, assuming that this
- instance contains state from the previous event and \a other contains new
- values that came in from a device.
-
- That is: global position and other valuators will be updated, but
- the following properties will not be updated:
- \li other properties that are not likely to be set after a fresh touchpoint
- has been received from a device
- \li properties that should be persistent between events (such as grabbers)
-*/
-void QMutableEventPoint::updateFrom(const QEventPoint &other)
-{
- detach();
- setPressure(other.pressure());
-
- switch (other.state()) {
- case QEventPoint::State::Pressed:
- setGlobalPressPosition(other.globalPosition());
- setGlobalLastPosition(other.globalPosition());
- if (pressure() < 0)
- setPressure(1);
- break;
-
- case QEventPoint::State::Released:
- if (globalPosition() != other.globalPosition())
- setGlobalLastPosition(globalPosition());
- setPressure(0);
- break;
-
- case QEventPoint::State::Stationary:
- // Stationary points might not be delivered down to the receiving item
- // and get their position transformed, keep the old values instead.
- if (other.velocity() != velocity() ||
- !qFuzzyCompare(other.pressure(), pressure())) {
- setStationaryWithModifiedProperty();
- }
- Q_FALLTHROUGH();
-
- default: // update or stationary
- if (globalPosition() != other.globalPosition())
- setGlobalLastPosition(globalPosition());
- if (pressure() < 0)
- setPressure(1);
- break;
- }
-
- setState(other.state());
- setPosition(other.position());
- setScenePosition(other.scenePosition());
- setGlobalPosition(other.globalPosition());
- setEllipseDiameters(other.ellipseDiameters());
- setRotation(other.rotation());
- setVelocity(other.velocity());
-}
-
-/*! \internal
- Set the timestamp from the event that updated this point's positions,
- and calculate a new value for velocity().
-
- The velocity calculation is done here because none of the QPointerEvent
- subclass constructors take the timestamp directly, and because
- QGuiApplication traditionally constructs an event first and then sets its
- timestamp (see for example QGuiApplicationPrivate::processMouseEvent()).
-
- This function looks up the corresponding instance in QPointingDevicePrivate::activePoints,
- and assumes that its timestamp() still holds the previous time when this point
- was updated, its velocity() holds this point's last-known velocity, and
- its globalPosition() and globalLastPosition() hold this point's current
- and previous positions, respectively. We assume timestamps are in milliseconds.
-
- The velocity calculation is skipped if the platform has promised to
- provide velocities already by setting the QInputDevice::Velocity capability.
-*/
-void QMutableEventPoint::setTimestamp(const ulong t)
-{
- // On mouse press, if the mouse has moved from its last-known location,
- // QGuiApplicationPrivate::processMouseEvent() sends first a mouse move and
- // then a press. Both events will get the same timestamp. So we need to set
- // the press timestamp and position even when the timestamp isn't advancing,
- // but skip setting lastTimestamp and velocity because those need a time delta.
- if (state() == QEventPoint::State::Pressed) {
- d->pressTimestamp = t;
- d->globalPressPos = d->globalPos;
- }
- if (d->timestamp == t)
- return;
- detach();
- if (device()) {
- // get the persistent instance out of QPointingDevicePrivate::activePoints
- // (which sometimes might be the same as this instance)
- QEventPointPrivate *pd = QPointingDevicePrivate::get(
- const_cast<QPointingDevice *>(d->device))->pointById(id())->eventPoint.d;
- if (t > pd->timestamp) {
- pd->lastTimestamp = pd->timestamp;
- pd->timestamp = t;
- if (state() == QEventPoint::State::Pressed)
- pd->pressTimestamp = t;
- if (pd->lastTimestamp > 0 && !device()->capabilities().testFlag(QInputDevice::Capability::Velocity)) {
- // calculate instantaneous velocity according to time and distance moved since the previous point
- QVector2D newVelocity = QVector2D(pd->globalPos - pd->globalLastPos) / (t - pd->lastTimestamp) * 1000;
- // VERY simple kalman filter: does a weighted average
- // where the older velocities get less and less significant
- static const float KalmanGain = 0.7f;
- pd->velocity = newVelocity * KalmanGain + pd->velocity * (1.0f - KalmanGain);
- qCDebug(lcPointerVel) << "velocity" << newVelocity << "filtered" << pd->velocity <<
- "based on movement" << pd->globalLastPos << "->" << pd->globalPos <<
- "over time" << pd->lastTimestamp << "->" << pd->timestamp;
- }
- if (d != pd) {
- d->lastTimestamp = pd->lastTimestamp;
- d->velocity = pd->velocity;
- }
- }
- }
- d->timestamp = t;
-}
-
-/*! \internal
- void QMutableEventPoint::setPosition(const QPointF &pos)
- Sets the localized position.
- Often events need to be localized before delivery to specific widgets or
- items. This can be done directly, or in a copy (for which we have a copy
- constructor), depending on whether the original point needs to be retained.
- Usually it's calculated by mapping scenePosition() to the target anyway.
-*/
-
-/*!
\class QPointerEvent
\since 6.0
\inmodule QtGui
@@ -575,15 +229,23 @@ void QMutableEventPoint::setTimestamp(const ulong t)
*/
/*!
- \fn int QPointerEvent::pointCount() const
+ \fn qsizetype QPointerEvent::pointCount() const
Returns the number of points in this pointer event.
*/
/*!
- \fn const QEventPoint &QPointerEvent::point(int i) const
+ Returns a QEventPoint reference for the point at index \a i.
+*/
+QEventPoint &QPointerEvent::point(qsizetype i)
+{
+ return m_points[i];
+}
- Returns a QEventPoint reference for a point at index \a i.
+/*!
+ \fn const QList<QEventPoint> &QPointerEvent::points() const
+
+ Returns a list of points in this pointer event.
*/
/*!
@@ -601,10 +263,16 @@ QPointerEvent::QPointerEvent(QEvent::Type type, const QPointingDevice *dev,
{
}
-QPointerEvent::~QPointerEvent()
+/*!
+ \internal
+*/
+QPointerEvent::QPointerEvent(QEvent::Type type, QEvent::SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers)
{
}
+Q_IMPL_POINTER_EVENT(QPointerEvent);
+
/*!
Returns the point whose \l {QEventPoint::id()}{id} matches the given \a id,
or \c nullptr if no such point is found.
@@ -619,12 +287,13 @@ QEventPoint *QPointerEvent::pointById(int id)
}
/*!
- Returns \c true if every point in points() has an exclusiveGrabber().
+ Returns \c true if every point in points() has either an exclusiveGrabber()
+ or one or more passiveGrabbers().
*/
bool QPointerEvent::allPointsGrabbed() const
{
for (const auto &p : points()) {
- if (exclusiveGrabber(p) && passiveGrabbers(p).isEmpty())
+ if (!exclusiveGrabber(p) && passiveGrabbers(p).isEmpty())
return false;
}
return true;
@@ -644,6 +313,16 @@ bool QPointerEvent::allPointsAccepted() const
}
/*!
+ \reimp
+*/
+void QPointerEvent::setAccepted(bool accepted)
+{
+ QEvent::setAccepted(accepted);
+ for (auto &p : m_points)
+ p.setAccepted(accepted);
+}
+
+/*!
Returns the source device from which this event originates.
This is the same as QInputEvent::device() but typecast for convenience.
@@ -656,11 +335,11 @@ const QPointingDevice *QPointerEvent::pointingDevice() const
/*! \internal
Sets the timestamp for this event and its points().
*/
-void QPointerEvent::setTimestamp(ulong timestamp)
+void QPointerEvent::setTimestamp(quint64 timestamp)
{
QInputEvent::setTimestamp(timestamp);
for (auto &p : m_points)
- QMutableEventPoint::from(p).setTimestamp(timestamp);
+ QMutableEventPoint::setTimestamp(p, timestamp);
}
/*!
@@ -698,7 +377,7 @@ void QPointerEvent::setExclusiveGrabber(const QEventPoint &point, QObject *exclu
Returns the list of objects that have been requested to receive all
future update events and the release event containing the given \a point.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
\sa QPointerEvent::addPassiveGrabber()
*/
@@ -718,7 +397,7 @@ QList<QPointer<QObject> > QPointerEvent::passiveGrabbers(const QEventPoint &poin
future update events and the release event containing the given \a point,
regardless where else those events may be delivered.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
Returns \c false if \a grabber was already added, \c true otherwise.
*/
@@ -733,7 +412,7 @@ bool QPointerEvent::addPassiveGrabber(const QEventPoint &point, QObject *grabber
Removes the passive \a grabber from the given \a point if it was previously added.
Returns \c true if it had been a passive grabber before, \c false if not.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
\sa QPointerEvent::addPassiveGrabber()
*/
@@ -747,7 +426,7 @@ bool QPointerEvent::removePassiveGrabber(const QEventPoint &point, QObject *grab
/*!
Removes all passive grabbers from the given \a point.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
\sa QPointerEvent::addPassiveGrabber()
*/
@@ -767,18 +446,6 @@ void QPointerEvent::clearPassiveGrabbers(const QEventPoint &point)
mouse events.
*/
-/*! \fn int QSinglePointEvent::pointCount() const
-
- Returns the number of points in the event. For a QSinglePointEvent, this
- is always 1.
-*/
-
-/*! \fn const QEventPoint &QSinglePointEvent::point(int i) const
-
- Returns a reference to a point at index \a i. For a QSinglePointEvent,
- \a i must be 0.
-*/
-
/*! \fn Qt::MouseButton QSinglePointEvent::button() const
Returns the button that caused the event.
@@ -795,7 +462,7 @@ void QPointerEvent::clearPassiveGrabbers(const QEventPoint &point)
Returns the button state when the event was generated.
The button state is a combination of Qt::LeftButton, Qt::RightButton,
- and Qt::MidButton using the OR operator.
+ and Qt::MiddleButton using the OR operator.
For mouse move or \l TabletMove events, this is all buttons that are
pressed down.
@@ -825,7 +492,7 @@ void QPointerEvent::clearPassiveGrabbers(const QEventPoint &point)
Returns the position of the point in this event, relative to the window or
scene.
- \sa QEventPoint::scenePosition()
+ \sa QEventPoint::scenePosition
*/
/*! \fn QPointF QSinglePointEvent::globalPosition() const
@@ -845,41 +512,45 @@ void QPointerEvent::clearPassiveGrabbers(const QEventPoint &point)
/*!
\internal
*/
-QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos,
- const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
- : QPointerEvent(type, dev, modifiers),
+QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *dev,
+ const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
+ : QPointerEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers),
m_button(button),
m_mouseState(buttons),
- m_source(Qt::MouseEventNotSynthesized),
- m_doubleClick(false),
- m_reserved(0)
+ m_source(source),
+ m_reserved(0), m_reserved2(0),
+ m_doubleClick(false), m_phase(0), m_invertedScrolling(0)
{
bool isPress = (button != Qt::NoButton && (button | buttons) == buttons);
bool isWheel = (type == QEvent::Type::Wheel);
auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
auto epd = devPriv->pointById(0);
- QMutableEventPoint &mut = QMutableEventPoint::from(epd->eventPoint);
- Q_ASSERT(mut.device() == dev);
- // mut is now a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints.
+ QEventPoint &p = epd->eventPoint;
+ Q_ASSERT(p.device() == dev);
+ // p is a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints.
// Update persistent info in that instance.
if (isPress || isWheel)
- mut.setGlobalLastPosition(globalPos);
+ QMutableEventPoint::setGlobalLastPosition(p, globalPos);
else
- mut.setGlobalLastPosition(mut.globalPosition());
- mut.setGlobalPosition(globalPos);
- if (isWheel && mut.state() != QEventPoint::State::Updated)
- mut.setGlobalPressPosition(globalPos);
- if (button == Qt::NoButton || isWheel)
- mut.setState(QEventPoint::State::Updated); // stationary only happens with touch events, not single-point events
+ QMutableEventPoint::setGlobalLastPosition(p, p.globalPosition());
+ QMutableEventPoint::setGlobalPosition(p, globalPos);
+ if (isWheel && p.state() != QEventPoint::State::Updated)
+ QMutableEventPoint::setGlobalPressPosition(p, globalPos);
+ if (type == MouseButtonDblClick)
+ QMutableEventPoint::setState(p, QEventPoint::State::Stationary);
+ else if (button == Qt::NoButton || isWheel)
+ QMutableEventPoint::setState(p, QEventPoint::State::Updated);
else if (isPress)
- mut.setState(QEventPoint::State::Pressed);
+ QMutableEventPoint::setState(p, QEventPoint::State::Pressed);
else
- mut.setState(QEventPoint::State::Released);
- mut.setScenePosition(scenePos);
+ QMutableEventPoint::setState(p, QEventPoint::State::Released);
+ QMutableEventPoint::setScenePosition(p, scenePos);
// Now detach, and update the detached instance with ephemeral state.
- mut.detach();
- mut.setPosition(localPos);
- m_points.append(mut);
+ QMutableEventPoint::detach(p);
+ QMutableEventPoint::setPosition(p, localPos);
+ m_points.append(p);
}
/*! \internal
@@ -893,22 +564,28 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *dev, const QEventPoint &point,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
- : QPointerEvent(type, dev, modifiers),
+ : QPointerEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers),
m_button(button),
m_mouseState(buttons),
m_source(source),
- m_doubleClick(false),
- m_reserved(0)
+ m_reserved(0), m_reserved2(0),
+ m_doubleClick(false), m_phase(0), m_invertedScrolling(0)
{
m_points << point;
}
+Q_IMPL_POINTER_EVENT(QSinglePointEvent)
+
/*!
Returns \c true if this event represents a \l {button()}{button} being pressed.
*/
bool QSinglePointEvent::isBeginEvent() const
{
- return m_button != Qt::NoButton && m_mouseState.testFlag(m_button);
+ // A double-click event does not begin a sequence: it comes after a press event,
+ // and while it tells which button caused the double-click, it doesn't represent
+ // a change of button state. So it's an update event.
+ return m_button != Qt::NoButton && m_mouseState.testFlag(m_button)
+ && type() != QEvent::MouseButtonDblClick;
}
/*!
@@ -916,7 +593,9 @@ bool QSinglePointEvent::isBeginEvent() const
*/
bool QSinglePointEvent::isUpdateEvent() const
{
- return m_button == Qt::NoButton;
+ // A double-click event is an update event even though it tells which button
+ // caused the double-click, because a MouseButtonPress event was sent right before it.
+ return m_button == Qt::NoButton || type() == QEvent::MouseButtonDblClick;
}
/*!
@@ -928,6 +607,20 @@ bool QSinglePointEvent::isEndEvent() const
}
/*!
+ \property QSinglePointEvent::exclusivePointGrabber
+ \brief the object that will receive future updates
+
+ The exclusive grabber is an object that has chosen to receive all future
+ update events and the release event containing the same point that this
+ event carries.
+
+ Setting the exclusivePointGrabber property is a convenience equivalent to:
+ \code
+ setExclusiveGrabber(points().first(), exclusiveGrabber);
+ \endcode
+*/
+
+/*!
\class QMouseEvent
\ingroup events
\inmodule QtGui
@@ -976,7 +669,10 @@ bool QSinglePointEvent::isEndEvent() const
QCursor::pos()
*/
+#if QT_DEPRECATED_SINCE(6, 4)
/*!
+ \deprecated [6.4] Use another constructor instead (global position is required).
+
Constructs a mouse event object originating from \a device.
The \a type parameter must be one of QEvent::MouseButtonPress,
@@ -1007,6 +703,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
button, buttons, modifiers)
{
}
+#endif
/*!
Constructs a mouse event object originating from \a device.
@@ -1062,21 +759,16 @@ QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPoin
const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source,
const QPointingDevice *device)
- : QSinglePointEvent(type, device, localPos, windowPos, globalPos, button, buttons, modifiers)
+ : QSinglePointEvent(type, device, localPos, windowPos, globalPos, button, buttons, modifiers, source)
{
- m_source = source;
}
-/*!
- \internal
-*/
-QMouseEvent::~QMouseEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QMouseEvent)
/*!
+ \fn Qt::MouseEventSource QMouseEvent::source() const
\since 5.3
- \deprecated in 6.0: use pointingDevice()
+ \deprecated [6.0] Use pointingDevice() instead.
Returns information about the mouse event source.
@@ -1092,7 +784,20 @@ QMouseEvent::~QMouseEvent()
\sa Qt::MouseEventSource
\sa QGraphicsSceneMouseEvent::source()
-*/
+
+ \note In Qt 5-based code, source() was often used to attempt to distinguish
+ mouse events from an actual mouse vs. those that were synthesized because
+ some legacy QQuickItem or QWidget subclass did not react to a QTouchEvent.
+ However, you could not tell whether it was synthesized from a QTouchEvent
+ or a QTabletEvent, and other information was lost. pointingDevice()
+ tells you the specific device that it came from, so you might check
+ \c {pointingDevice()->type()} or \c {pointingDevice()->capabilities()} to
+ decide how to react to this event. But it's even better to react to the
+ original event rather than handling only mouse events.
+*/
+// Note: the docs mention 6.0 as a deprecation version. That is correct and
+// intended, because we want our users to stop using it! Internally we will
+// deprecate it when we port our code away from using it.
Qt::MouseEventSource QMouseEvent::source() const
{
return Qt::MouseEventSource(m_source);
@@ -1115,6 +820,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPointF QMouseEvent::localPos() const
+ \deprecated [6.0] Use position() instead.
\since 5.0
@@ -1142,6 +848,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPointF QMouseEvent::windowPos() const
+ \deprecated [6.0] Use scenePosition() instead.
\since 5.0
@@ -1157,6 +864,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPointF QMouseEvent::screenPos() const
+ \deprecated [6.0] Use globalPosition() instead.
\since 5.0
@@ -1168,6 +876,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPoint QMouseEvent::pos() const
+ \deprecated [6.0] Use position() instead.
Returns the position of the mouse cursor, relative to the widget
that received the event.
@@ -1181,6 +890,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPoint QMouseEvent::globalPos() const
+ \deprecated [6.0] Use globalPosition().toPoint() instead.
Returns the global position of the mouse cursor \e{at the time
of the event}. This is important on asynchronous window systems
@@ -1194,6 +904,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::x() const
+ \deprecated [6.0] Use position().x() instead.
Returns the x position of the mouse cursor, relative to the
widget that received the event.
@@ -1203,6 +914,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::y() const
+ \deprecated [6.0] Use position().y() instead.
Returns the y position of the mouse cursor, relative to the
widget that received the event.
@@ -1212,6 +924,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::globalX() const
+ \deprecated [6.0] Use globalPosition().x() instead.
Returns the global x position of the mouse cursor at the time of
the event.
@@ -1221,6 +934,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::globalY() const
+ \deprecated [6.0] Use globalPosition().y() instead.
Returns the global y position of the mouse cursor at the time of
the event.
@@ -1229,31 +943,6 @@ Qt::MouseEventFlags QMouseEvent::flags() const
*/
/*!
- \fn Qt::MouseButton QMouseEvent::button() const
-
- Returns the button that caused the event.
-
- Note that the returned value is always Qt::NoButton for mouse
- move events.
-
- \sa buttons(), Qt::MouseButton
-*/
-
-/*!
- \fn Qt::MouseButton QMouseEvent::buttons() const
-
- Returns the button state when the event was generated. The button
- state is a combination of Qt::LeftButton, Qt::RightButton,
- Qt::MiddleButton using the OR operator. For mouse move events,
- this is all buttons that are pressed down. For mouse press and
- double click events this includes the button that caused the
- event. For mouse release events this excludes the button that
- caused the event.
-
- \sa button(), Qt::MouseButton
-*/
-
-/*!
\class QHoverEvent
\ingroup events
\inmodule QtGui
@@ -1303,6 +992,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPoint QHoverEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the mouse cursor, relative to the widget
that received the event.
@@ -1328,6 +1018,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn const QPointF &QHoverEvent::posF() const
+ \deprecated [6.0] Use position() instead.
Returns the position of the mouse cursor, relative to the widget
that received the event.
@@ -1357,23 +1048,40 @@ Qt::MouseEventFlags QMouseEvent::flags() const
The \a type parameter must be QEvent::HoverEnter,
QEvent::HoverLeave, or QEvent::HoverMove.
- The \a pos is the current mouse cursor's position relative to the
- receiving widget, while \a oldPos is its previous such position.
+ The \a scenePos is the current mouse cursor's position relative to the
+ receiving window or scene, \a oldPos is its previous such position, and
+ \a globalPos is the mouse position in absolute coordinates.
\a modifiers hold the state of all keyboard modifiers at the time
of the event.
*/
-QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
+QHoverEvent::QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos,
Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
- : QSinglePointEvent(type, device, pos, pos, pos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
+ : QSinglePointEvent(type, device, scenePos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
{
}
+#if QT_DEPRECATED_SINCE(6, 3)
/*!
- \internal
+ \deprecated [6.3] Use the other constructor instead (global position is required).
+
+ Constructs a hover event object originating from \a device.
+
+ The \a type parameter must be QEvent::HoverEnter,
+ QEvent::HoverLeave, or QEvent::HoverMove.
+
+ The \a pos is the current mouse cursor's position relative to the
+ receiving widget, while \a oldPos is its previous such position.
+ \a modifiers hold the state of all keyboard modifiers at the time
+ of the event.
*/
-QHoverEvent::~QHoverEvent()
+QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
+ Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
+ : QSinglePointEvent(type, device, pos, pos, pos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
{
}
+#endif
+
+Q_IMPL_POINTER_EVENT(QHoverEvent)
#if QT_CONFIG(wheelevent)
/*!
@@ -1419,7 +1127,7 @@ QHoverEvent::~QHoverEvent()
/*!
\fn Qt::MouseEventSource QWheelEvent::source() const
\since 5.5
- \deprecated in 6.0: use pointingDevice()
+ \deprecated [6.0] Use pointingDevice() instead.
Returns information about the wheel event source.
@@ -1491,18 +1199,14 @@ QHoverEvent::~QHoverEvent()
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
bool inverted, Qt::MouseEventSource source, const QPointingDevice *device)
- : QSinglePointEvent(Wheel, device, pos, pos, globalPos, Qt::NoButton, buttons, modifiers),
- m_phase(phase), m_invertedScrolling(inverted), m_pixelDelta(pixelDelta), m_angleDelta(angleDelta)
+ : QSinglePointEvent(Wheel, device, pos, pos, globalPos, Qt::NoButton, buttons, modifiers, source),
+ m_pixelDelta(pixelDelta), m_angleDelta(angleDelta)
{
- m_source = source;
+ m_phase = phase;
+ m_invertedScrolling = inverted;
}
-/*!
- \internal
-*/
-QWheelEvent::~QWheelEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QWheelEvent)
/*!
Returns \c true if this event's phase() is Qt::ScrollBegin.
@@ -1547,7 +1251,7 @@ bool QWheelEvent::isEndEvent() const
\li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
\li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
\endlist
- \note On X11 this value is driver specific and unreliable, use angleDelta() instead
+ \note On X11 this value is driver-specific and unreliable, use angleDelta() instead.
*/
/*!
@@ -1643,9 +1347,9 @@ bool QWheelEvent::isEndEvent() const
in the event.
*/
QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
- bool autorep, ushort count)
+ bool autorep, quint16 count)
: QInputEvent(type, QInputDevice::primaryKeyboard(), modifiers), m_text(text), m_key(key),
- m_scanCode(0), m_virtualKey(0), m_modifiers(0),
+ m_scanCode(0), m_virtualKey(0), m_nativeModifiers(0),
m_count(count), m_autoRepeat(autorep)
{
if (type == QEvent::ShortcutOverride)
@@ -1672,9 +1376,9 @@ QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const
*/
QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
- const QString &text, bool autorep, ushort count, const QInputDevice *device)
+ const QString &text, bool autorep, quint16 count, const QInputDevice *device)
: QInputEvent(type, device, modifiers), m_text(text), m_key(key),
- m_scanCode(nativeScanCode), m_virtualKey(nativeVirtualKey), m_modifiers(nativeModifiers),
+ m_scanCode(nativeScanCode), m_virtualKey(nativeVirtualKey), m_nativeModifiers(nativeModifiers),
m_count(count), m_autoRepeat(autorep)
{
if (type == QEvent::ShortcutOverride)
@@ -1682,26 +1386,17 @@ QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
}
-/*!
- \internal
-*/
-QKeyEvent::~QKeyEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QKeyEvent)
/*!
- \fn quint32 QKeyEvent::nativeScanCode() const
- \since 4.2
-
- Returns the native scan code of the key event. If the key event
- does not contain this data 0 is returned.
+ \fn quint32 QKeyEvent::nativeScanCode() const
+ \since 4.2
- Note: The native scan code may be 0, even if the key event contains
- extended information.
+ Returns the native scan code of the key event. If the key event
+ does not contain this data 0 is returned.
- Note: On \macos, this function is not useful, because there is no
- way to get the scan code from the system APIs. The function always
- returns 1 (or 0 in the case explained above).
+ \note The native scan code may be 0, even if the key event contains
+ extended information.
*/
/*!
@@ -1711,7 +1406,7 @@ QKeyEvent::~QKeyEvent()
Returns the native virtual key, or key sym of the key event.
If the key event does not contain this data 0 is returned.
- Note: The native virtual key may be 0, even if the key event contains extended information.
+ \note The native virtual key may be 0, even if the key event contains extended information.
*/
/*!
@@ -1721,7 +1416,7 @@ QKeyEvent::~QKeyEvent()
Returns the native modifiers of a key event.
If the key event does not contain this data 0 is returned.
- Note: The native modifiers may be 0, even if the key event contains extended information.
+ \note The native modifiers may be 0, even if the key event contains extended information.
*/
/*!
@@ -1748,12 +1443,13 @@ QKeyEvent::~QKeyEvent()
Returns the Unicode text that this key generated.
- Return values when modifier keys such as
- Shift, Control, Alt, and Meta are pressed
- differ among platforms and could return an empty string.
+ The text is not limited to the printable range of Unicode
+ code points, and may include control characters or characters
+ from other Unicode categories, including QChar::Other_PrivateUse.
- \note \l key() will always return a valid value,
- independent of modifier keys.
+ The text may also be empty, for example when modifier keys such as
+ Shift, Control, Alt, and Meta are pressed (depending on the platform).
+ The key() function will always return a valid value.
\sa Qt::WA_KeyCompression
*/
@@ -1865,12 +1561,7 @@ QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
: QEvent(type), m_reason(reason)
{}
-/*!
- \internal
-*/
-QFocusEvent::~QFocusEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QFocusEvent)
/*!
Returns the reason for this focus event.
@@ -1943,12 +1634,7 @@ QPaintEvent::QPaintEvent(const QRect &paintRect)
{}
-/*!
- \internal
-*/
-QPaintEvent::~QPaintEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QPaintEvent)
/*!
\fn const QRect &QPaintEvent::rect() const
@@ -1990,12 +1676,7 @@ QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
: QEvent(Move), m_pos(pos), m_oldPos(oldPos)
{}
-/*!
- \internal
-*/
-QMoveEvent::~QMoveEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QMoveEvent)
/*!
\fn const QPoint &QMoveEvent::pos() const
@@ -2042,12 +1723,7 @@ QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
{
}
-/*!
- \internal
-*/
-QExposeEvent::~QExposeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QExposeEvent)
/*!
\class QPlatformSurfaceEvent
@@ -2091,15 +1767,11 @@ QPlatformSurfaceEvent::QPlatformSurfaceEvent(SurfaceEventType surfaceEventType)
{
}
-/*!
- \internal
-*/
-QPlatformSurfaceEvent::~QPlatformSurfaceEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QPlatformSurfaceEvent)
/*!
\fn const QRegion &QExposeEvent::region() const
+ \deprecated [6.0] Use QPaintEvent instead.
Returns the window area that has been exposed. The region is given in local coordinates.
*/
@@ -2126,12 +1798,7 @@ QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
: QEvent(Resize), m_size(size), m_oldSize(oldSize)
{}
-/*!
- \internal
-*/
-QResizeEvent::~QResizeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QResizeEvent)
/*!
\fn const QSize &QResizeEvent::size() const
@@ -2173,10 +1840,6 @@ QResizeEvent::~QResizeEvent()
special handling, you should reimplement the event handler and
ignore() the event.
- The \l{mainwindows/application#close event handler}{closeEvent() in the
- Application example} shows a close event handler that
- asks whether to save a document before closing.
-
If you want the widget to be deleted when it is closed, create it
with the Qt::WA_DeleteOnClose flag. This is very useful for
independent top-level windows in a multi-window application.
@@ -2206,11 +1869,7 @@ QCloseEvent::QCloseEvent()
: QEvent(Close)
{}
-/*! \internal
-*/
-QCloseEvent::~QCloseEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QCloseEvent)
/*!
\class QIconDragEvent
@@ -2239,10 +1898,7 @@ QIconDragEvent::QIconDragEvent()
: QEvent(IconDrag)
{ ignore(); }
-/*! \internal */
-QIconDragEvent::~QIconDragEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QIconDragEvent)
/*!
\class QContextMenuEvent
@@ -2259,11 +1915,6 @@ QIconDragEvent::~QIconDragEvent()
When this event occurs it is customary to show a QMenu with a
context menu, if this is relevant to the context.
-
- Context menu events contain a special accept flag that indicates
- whether the receiver accepted the event. If the event handler does
- not accept the event then, if possible, whatever triggered the event will be
- handled as a regular input event.
*/
#ifndef QT_NO_CONTEXTMENU
@@ -2276,21 +1927,6 @@ QIconDragEvent::~QIconDragEvent()
The \a pos parameter specifies the mouse position relative to the
receiving widget. \a globalPos is the mouse position in absolute
- coordinates.
-*/
-QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
- : QContextMenuEvent(reason, pos, globalPos, Qt::NoModifier)
-{}
-
-/*!
- Constructs a context menu event object with the accept parameter
- flag set to false.
-
- The \a reason parameter must be QContextMenuEvent::Mouse or
- QContextMenuEvent::Keyboard.
-
- The \a pos parameter specifies the mouse position relative to the
- receiving widget. \a globalPos is the mouse position in absolute
coordinates. The \a modifiers holds the keyboard modifiers.
*/
QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
@@ -2298,12 +1934,12 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPo
: QInputEvent(ContextMenu, QPointingDevice::primaryPointingDevice(), modifiers), m_pos(pos), m_globalPos(globalPos), m_reason(reason)
{}
+Q_IMPL_EVENT_COMMON(QContextMenuEvent)
-/*! \internal */
-QContextMenuEvent::~QContextMenuEvent()
-{
-}
+#if QT_DEPRECATED_SINCE(6, 4)
/*!
+ \deprecated [6.4] Use the other constructor instead (global position is required).
+
Constructs a context menu event object with the accept parameter
flag set to false.
@@ -2324,6 +1960,7 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
m_globalPos = QCursor::pos();
#endif
}
+#endif
/*!
\fn const QPoint &QContextMenuEvent::pos() const
@@ -2458,7 +2095,7 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
has to be inserted to the widgets text directly before the preedit
string.
- If the commitString() should replace parts of the of the text in
+ If the commitString() should replace parts of the text in
the editor, replacementLength() will contain the number of
characters to be replaced. replacementStart() contains the position
at which characters are to be replaced relative from the start of
@@ -2614,18 +2251,7 @@ QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Att
{
}
-/*!
- Constructs a copy of \a other.
-*/
-QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
- : QEvent(QEvent::InputMethod), m_preedit(other.m_preedit), m_attributes(other.m_attributes),
- m_commit(other.m_commit), m_replacementStart(other.m_replacementStart), m_replacementLength(other.m_replacementLength)
-{
-}
-
-QInputMethodEvent::~QInputMethodEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QInputMethodEvent)
/*!
Sets the commit string to \a commitString.
@@ -2635,7 +2261,7 @@ QInputMethodEvent::~QInputMethodEvent()
result of the input operations and has to be inserted to the
widgets text directly before the preedit string.
- If the commit string should replace parts of the of the text in
+ If the commit string should replace parts of the text in
the editor, \a replaceLength specifies the number of
characters to be replaced. \a replaceFrom specifies the position
at which characters are to be replaced relative from the start of
@@ -2732,12 +2358,7 @@ QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
{
}
-/*!
- \internal
- */
-QInputMethodQueryEvent::~QInputMethodQueryEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QInputMethodQueryEvent)
/*!
Sets property \a query to \a value.
@@ -2874,27 +2495,22 @@ QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
tangentialPressure(), z()
*/
QTabletEvent::QTabletEvent(Type type, const QPointingDevice *dev, const QPointF &pos, const QPointF &globalPos,
- qreal pressure, int xTilt, int yTilt,
- qreal tangentialPressure, qreal rotation, int z,
+ qreal pressure, float xTilt, float yTilt,
+ float tangentialPressure, qreal rotation, float z,
Qt::KeyboardModifiers keyState,
Qt::MouseButton button, Qt::MouseButtons buttons)
: QSinglePointEvent(type, dev, pos, pos, globalPos, button, buttons, keyState),
+ m_tangential(tangentialPressure),
m_xTilt(xTilt),
m_yTilt(yTilt),
- m_z(z),
- m_tangential(tangentialPressure)
+ m_z(z)
{
- QMutableEventPoint &mut = QMutableEventPoint::from(point(0));
- mut.setPressure(pressure);
- mut.setRotation(rotation);
+ QEventPoint &p = point(0);
+ QMutableEventPoint::setPressure(p, pressure);
+ QMutableEventPoint::setRotation(p, rotation);
}
-/*!
- \internal
-*/
-QTabletEvent::~QTabletEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QTabletEvent)
/*!
\fn qreal QTabletEvent::tangentialPressure() const
@@ -2905,6 +2521,8 @@ QTabletEvent::~QTabletEvent()
direction from the neutrual position. If the device does not support
tangential pressure, this value is always 0.0.
+ \note The value is stored as a single-precision float.
+
\sa pressure()
*/
@@ -2929,7 +2547,7 @@ QTabletEvent::~QTabletEvent()
*/
/*!
- \fn int QTabletEvent::xTilt() const
+ \fn qreal QTabletEvent::xTilt() const
Returns the angle between the device (a pen, for example) and the
perpendicular in the direction of the x axis.
@@ -2938,22 +2556,27 @@ QTabletEvent::~QTabletEvent()
\image qtabletevent-tilt.png
+ \note The value is stored as a single-precision float.
+
\sa yTilt()
*/
/*!
- \fn int QTabletEvent::yTilt() const
+ \fn qreal QTabletEvent::yTilt() const
Returns the angle between the device (a pen, for example) and the
perpendicular in the direction of the y axis.
Positive values are towards the bottom of the tablet. The angle is
within the range -60 to +60 degrees.
+ \note The value is stored as a single-precision float.
+
\sa xTilt()
*/
/*!
\fn QPoint QTabletEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the device, relative to the widget that
received the event.
@@ -2966,6 +2589,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::x() const
+ \deprecated [6.0] Use position().x() instead.
Returns the x position of the device, relative to the widget that
received the event.
@@ -2975,6 +2599,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::y() const
+ \deprecated [6.0] Use position().y() instead.
Returns the y position of the device, relative to the widget that
received the event.
@@ -2983,17 +2608,20 @@ QTabletEvent::~QTabletEvent()
*/
/*!
- \fn int QTabletEvent::z() const
+ \fn qreal QTabletEvent::z() const
Returns the z position of the device. Typically this is represented by a
wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
always zero. This is \b not the same as pressure.
+ \note The value is stored as a single-precision float.
+
\sa pressure()
*/
/*!
\fn QPoint QTabletEvent::globalPos() const
+ \deprecated [6.0] Use globalPosition().toPoint() instead.
Returns the global position of the device \e{at the time of the
event}. This is important on asynchronous windows systems like X11;
@@ -3006,6 +2634,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::globalX() const
+ \deprecated [6.0] Use globalPosition().x() instead.
Returns the global x position of the mouse pointer at the time of
the event.
@@ -3015,6 +2644,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::globalY() const
+ \deprecated [6.0] Use globalPosition().y() instead.
Returns the global y position of the tablet device at the time of
the event.
@@ -3024,6 +2654,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn qint64 QTabletEvent::uniqueId() const
+ \deprecated [6.0] Use pointingDevice().uniqueId() instead.
Returns a unique ID for the current device, making it possible
to differentiate between multiple devices being used at the same
@@ -3047,6 +2678,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn const QPointF &QTabletEvent::posF() const
+ \deprecated [6.0] Use position() instead.
Returns the position of the device, relative to the widget that
received the event.
@@ -3059,7 +2691,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn const QPointF &QTabletEvent::globalPosF() const
-
+ \deprecated [6.0] Use globalPosition() instead.
Returns the global position of the device \e{at the time of the
event}. This is important on asynchronous windows systems like X11;
whenever you move your widgets around in response to mouse events,
@@ -3080,8 +2712,10 @@ QTabletEvent::~QTabletEvent()
\ingroup events
Native gesture events are generated by the operating system, typically by
- interpreting touch events. Gesture events are high-level events such
- as zoom or rotate.
+ interpreting trackpad touch events. Gesture events are high-level events
+ such as zoom, rotate or pan. Several types hold incremental values: that is,
+ value() and delta() provide the difference from the previous event to the
+ current event.
\table
\header
@@ -3091,7 +2725,7 @@ QTabletEvent::~QTabletEvent()
\row
\li Qt::ZoomNativeGesture
\li Magnification delta in percent.
- \li \macos: Two-finger pinch.
+ \li \macos and Wayland: Two-finger pinch.
\row
\li Qt::SmartZoomNativeGesture
\li Boolean magnification state.
@@ -3099,10 +2733,17 @@ QTabletEvent::~QTabletEvent()
\row
\li Qt::RotateNativeGesture
\li Rotation delta in degrees.
- \li \macos: Two-finger rotate.
+ \li \macos and Wayland: Two-finger rotate.
+ \row
+ \li Qt::SwipeNativeGesture
+ \li Swipe angle in degrees.
+ \li \macos: Configurable in trackpad settings.
+ \row
+ \li Qt::PanNativeGesture
+ \li Displacement delta in pixels.
+ \li Wayland: Three or more fingers moving as a group, in any direction.
\endtable
-
In addition, BeginNativeGesture and EndNativeGesture are sent before and after
gesture event streams:
@@ -3112,10 +2753,26 @@ QTabletEvent::~QTabletEvent()
ZoomNativeGesture
EndNativeGesture
- \sa Qt::NativeGestureType, QGestureEvent
+ The event stream may include interleaved gestures of different types:
+ for example the two-finger pinch gesture generates a stream of Zoom and
+ Rotate events, and PanNativeGesture may sometimes be interleaved with
+ those, depending on the platform.
+
+ Other types are standalone events: SmartZoomNativeGesture and
+ SwipeNativeGesture occur only once each time the gesture is detected.
+
+ \note On a touchpad, moving two fingers as a group (the two-finger flick gesture)
+ is usually reserved for scrolling; in that case, Qt generates QWheelEvents.
+ This is the reason that three or more fingers are needed to generate a
+ PanNativeGesture.
+
+ \sa Qt::NativeGestureType, QGestureEvent, QWheelEvent
*/
+#if QT_DEPRECATED_SINCE(6, 2)
/*!
+ \deprecated [6.2] Use the other constructor, because \a intValue is no longer stored separately.
+
Constructs a native gesture event of type \a type originating from \a device.
The points \a localPos, \a scenePos and \a globalPos specify the
@@ -3124,17 +2781,60 @@ QTabletEvent::~QTabletEvent()
\a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters.
\since 5.10
+
+ \note It's not possible to store realValue and \a intValue simultaneously:
+ one or the other must be zero. If \a realValue == 0 and \a intValue != 0,
+ it is stored in the same variable, such that value() returns the value
+ given as \a intValue.
*/
-QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device, const QPointF &localPos, const QPointF &scenePos,
- const QPointF &globalPos, qreal realValue, ulong sequenceId, quint64 intValue)
- : QSinglePointEvent(QEvent::NativeGesture, device, localPos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier),
- m_gestureType(type), m_realValue(realValue), m_sequenceId(sequenceId),
- m_intValue(intValue)
+QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device,
+ const QPointF &localPos, const QPointF &scenePos,
+ const QPointF &globalPos, qreal realValue, quint64 sequenceId,
+ quint64 intValue)
+ : QSinglePointEvent(QEvent::NativeGesture, device, localPos, scenePos, globalPos, Qt::NoButton,
+ Qt::NoButton, Qt::NoModifier),
+ m_sequenceId(sequenceId), m_realValue(realValue), m_gestureType(type)
{
+ if (qIsNull(realValue) && intValue != 0)
+ m_realValue = intValue;
}
+#endif // deprecated
-QNativeGestureEvent::~QNativeGestureEvent()
- = default;
+/*!
+ Constructs a native gesture event of type \a type originating from \a device
+ describing a gesture at \a scenePos in which \a fingerCount fingers are involved.
+
+ The points \a localPos, \a scenePos and \a globalPos specify the gesture
+ position relative to the receiving widget or item, window, and screen or
+ desktop, respectively.
+
+ \a value has a gesture-dependent interpretation: for RotateNativeGesture or
+ SwipeNativeGesture, it's an angle in degrees. For ZoomNativeGesture,
+ \a value is an incremental scaling factor, usually much less than 1,
+ indicating that the target item should have its scale adjusted like this:
+ item.scale = item.scale * (1 + event.value)
+
+ For PanNativeGesture, \a delta gives the distance in pixels that the
+ viewport, widget or item should be moved or panned.
+
+ \note The \a delta is stored in single precision (QVector2D), so \l delta()
+ may return slightly different values in some cases. This is subject to change
+ in future versions of Qt.
+
+ \since 6.2
+*/
+QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device, int fingerCount,
+ const QPointF &localPos, const QPointF &scenePos,
+ const QPointF &globalPos, qreal value, const QPointF &delta,
+ quint64 sequenceId)
+ : QSinglePointEvent(QEvent::NativeGesture, device, localPos, scenePos, globalPos, Qt::NoButton,
+ Qt::NoButton, Qt::NoModifier),
+ m_sequenceId(sequenceId), m_delta(delta), m_realValue(value), m_gestureType(type), m_fingerCount(fingerCount)
+{
+ Q_ASSERT(fingerCount < 16); // we store it in 4 bits unsigned
+}
+
+Q_IMPL_POINTER_EVENT(QNativeGestureEvent)
/*!
\fn QNativeGestureEvent::gestureType() const
@@ -3144,19 +2844,40 @@ QNativeGestureEvent::~QNativeGestureEvent()
*/
/*!
+ \fn QNativeGestureEvent::fingerCount() const
+ \since 6.2
+
+ Returns the number of fingers participating in the gesture, if known.
+ When gestureType() is Qt::BeginNativeGesture or Qt::EndNativeGesture, often
+ this information is unknown, and fingerCount() returns \c 0.
+*/
+
+/*!
\fn QNativeGestureEvent::value() const
\since 5.2
Returns the gesture value. The value should be interpreted based on the
- gesture type. For example, a Zoom gesture provides a scale factor while a Rotate
+ gesture type. For example, a Zoom gesture provides a scale factor delta while a Rotate
gesture provides a rotation delta.
\sa QNativeGestureEvent, gestureType()
*/
/*!
+ \fn QNativeGestureEvent::delta() const
+ \since 6.2
+
+ Returns the distance moved since the previous event, in pixels.
+ A Pan gesture provides the distance in pixels by which the target widget,
+ item or viewport contents should be moved.
+
+ \sa QPanGesture::delta()
+*/
+
+/*!
\fn QPoint QNativeGestureEvent::globalPos() const
\since 5.2
+ \deprecated [6.0] Use globalPosition().toPoint() instead.
Returns the position of the gesture as a QPointF in screen coordinates
*/
@@ -3164,6 +2885,7 @@ QNativeGestureEvent::~QNativeGestureEvent()
/*!
\fn QPoint QNativeGestureEvent::pos() const
\since 5.2
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the mouse cursor, relative to the widget
or item that received the event.
@@ -3172,6 +2894,7 @@ QNativeGestureEvent::~QNativeGestureEvent()
/*!
\fn QPointF QNativeGestureEvent::localPos() const
\since 5.2
+ \deprecated [6.0] Use position() instead.
Returns the position of the gesture as a QPointF, relative to the
widget or item that received the event.
@@ -3180,6 +2903,7 @@ QNativeGestureEvent::~QNativeGestureEvent()
/*!
\fn QPointF QNativeGestureEvent::screenPos() const
\since 5.2
+ \deprecated [6.0] Use globalPosition() instead.
Returns the position of the gesture as a QPointF in screen coordinates.
*/
@@ -3187,6 +2911,7 @@ QNativeGestureEvent::~QNativeGestureEvent()
/*!
\fn QPointF QNativeGestureEvent::windowPos() const
\since 5.2
+ \deprecated [6.0] Use scenePosition() instead.
Returns the position of the gesture as a QPointF, relative to the
window that received the event.
@@ -3212,12 +2937,7 @@ QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const
, m_rect(pos, QSize(1, 1))
{}
-/*!
- Destroys the event.
-*/
-QDragMoveEvent::~QDragMoveEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDragMoveEvent)
/*!
\fn void QDragMoveEvent::accept(const QRect &rectangle)
@@ -3330,10 +3050,7 @@ QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeD
ignore();
}
-/*! \internal */
-QDropEvent::~QDropEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDropEvent)
/*!
@@ -3364,24 +3081,49 @@ void QDropEvent::setDropAction(Qt::DropAction action)
/*!
\fn QPoint QDropEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position where the drop was made.
*/
/*!
\fn const QPointF& QDropEvent::posF() const
+ \deprecated [6.0] Use position() instead.
+
+ Returns the position where the drop was made.
+*/
+
+/*!
+ \fn QPointF QDropEvent::position() const
+ \since 6.0
Returns the position where the drop was made.
*/
/*!
\fn Qt::MouseButtons QDropEvent::mouseButtons() const
+ \deprecated [6.0] Use buttons() instead.
+
+ Returns the mouse buttons that are pressed.
+*/
+
+/*!
+ \fn Qt::MouseButtons QDropEvent::buttons() const
+ \since 6.0
- Returns the mouse buttons that are pressed..
+ Returns the mouse buttons that are pressed.
*/
/*!
\fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
+ \deprecated [6.0] Use modifiers() instead.
+
+ Returns the modifier keys that are pressed.
+*/
+
+/*!
+ \fn Qt::KeyboardModifiers QDropEvent::modifiers() const
+ \since 6.0
Returns the modifier keys that are pressed.
*/
@@ -3474,11 +3216,7 @@ QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, c
: QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
{}
-/*! \internal
-*/
-QDragEnterEvent::~QDragEnterEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDragEnterEvent)
/*!
\class QDragMoveEvent
@@ -3532,11 +3270,8 @@ QDragLeaveEvent::QDragLeaveEvent()
: QEvent(DragLeave)
{}
-/*! \internal
-*/
-QDragLeaveEvent::~QDragLeaveEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDragLeaveEvent)
+
#endif // QT_CONFIG(draganddrop)
/*!
@@ -3618,11 +3353,7 @@ QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
\sa pos(), globalX(), globalY()
*/
-/*! \internal
-*/
-QHelpEvent::~QHelpEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QHelpEvent)
#ifndef QT_NO_STATUSTIP
@@ -3677,11 +3408,7 @@ QStatusTipEvent::QStatusTipEvent(const QString &tip)
: QEvent(StatusTip), m_tip(tip)
{}
-/*! \internal
-*/
-QStatusTipEvent::~QStatusTipEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QStatusTipEvent)
/*!
\fn QString QStatusTipEvent::tip() const
@@ -3717,11 +3444,7 @@ QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
: QEvent(WhatsThisClicked), m_href(href)
{}
-/*! \internal
-*/
-QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QWhatsThisClickedEvent)
/*!
\fn QString QWhatsThisClickedEvent::href() const
@@ -3763,11 +3486,7 @@ QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
: QEvent(static_cast<QEvent::Type>(type)), m_action(action), m_before(before)
{}
-/*! \internal
-*/
-QActionEvent::~QActionEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QActionEvent)
/*!
\fn QAction *QActionEvent::action() const
@@ -3817,11 +3536,7 @@ QHideEvent::QHideEvent()
: QEvent(Hide)
{}
-/*! \internal
-*/
-QHideEvent::~QHideEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QHideEvent)
/*!
\class QShowEvent
@@ -3847,11 +3562,7 @@ QShowEvent::QShowEvent()
: QEvent(Show)
{}
-/*! \internal
-*/
-QShowEvent::~QShowEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QShowEvent)
/*!
\class QFileOpenEvent
@@ -3882,10 +3593,15 @@ QShowEvent::~QShowEvent()
\snippet qfileopenevent/Info.plist Custom Info.plist
- The following implementation of a QApplication subclass prints the path to
- the file that was, for example, dropped on the Dock icon of the application.
+ The following implementation of a QApplication subclass shows how to handle
+ QFileOpenEvent to open the file that was, for example, dropped on the Dock
+ icon of the application.
\snippet qfileopenevent/main.cpp QApplication subclass
+
+ Note how \c{QFileOpenEvent::file()} is not guaranteed to be the name of a
+ local file that can be opened using QFile. The contents of the string depend
+ on the source application.
*/
/*!
@@ -3908,29 +3624,28 @@ QFileOpenEvent::QFileOpenEvent(const QUrl &url)
{
}
-
-/*! \internal
-*/
-QFileOpenEvent::~QFileOpenEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QFileOpenEvent)
/*!
\fn QString QFileOpenEvent::file() const
- Returns the file that is being opened.
+ Returns the name of the file that the application should open.
+
+ This is not guaranteed to be the path to a local file.
*/
/*!
\fn QUrl QFileOpenEvent::url() const
- Returns the url that is being opened.
+ Returns the url that the application should open.
\since 4.6
*/
+#if QT_DEPRECATED_SINCE(6, 6)
/*!
\fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
+ \deprecated [6.6] interpret the string returned by file()
Opens a QFile on the \a file referenced by this event in the mode specified
by \a flags. Returns \c true if successful; otherwise returns \c false.
@@ -3945,6 +3660,7 @@ bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
file.setFileName(m_file);
return file.open(flags);
}
+#endif
#ifndef QT_NO_TOOLBAR
/*!
@@ -3971,11 +3687,7 @@ QToolBarChangeEvent::QToolBarChangeEvent(bool t)
: QEvent(ToolBarChange), m_toggle(t)
{}
-/*! \internal
-*/
-QToolBarChangeEvent::~QToolBarChangeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QToolBarChangeEvent)
/*!
\fn bool QToolBarChangeEvent::toggle() const
@@ -4000,21 +3712,40 @@ QToolBarChangeEvent::~QToolBarChangeEvent()
Constructs a shortcut event for the given \a key press,
associated with the QShortcut ID \a id.
+ \deprecated use the other constructor
+
\a ambiguous specifies whether there is more than one QShortcut
for the same key sequence.
*/
QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
- : QEvent(Shortcut), m_sequence(key), m_ambiguous(ambiguous), m_shortcutId(id)
+ : QEvent(Shortcut), m_sequence(key), m_shortcutId(id), m_ambiguous(ambiguous)
{
}
/*!
- Destroys the event object.
+ Constructs a shortcut event for the given \a key press,
+ associated with the QShortcut \a shortcut.
+ \since 6.5
+
+ \a ambiguous specifies whether there is more than one QShortcut
+ for the same key sequence.
*/
-QShortcutEvent::~QShortcutEvent()
+QShortcutEvent::QShortcutEvent(const QKeySequence &key, const QShortcut *shortcut, bool ambiguous)
+ : QEvent(Shortcut), m_sequence(key), m_shortcutId(0), m_ambiguous(ambiguous)
{
+ if (shortcut) {
+ auto priv = static_cast<const QShortcutPrivate *>(QShortcutPrivate::get(shortcut));
+ auto index = priv->sc_sequences.indexOf(key);
+ if (index < 0) {
+ qWarning() << "Given QShortcut does not contain key-sequence " << key;
+ return;
+ }
+ m_shortcutId = priv->sc_ids[index];
+ }
}
+Q_IMPL_EVENT_COMMON(QShortcutEvent)
+
#endif // QT_CONFIG(shortcut)
#ifndef QT_NO_DEBUG_STREAM
@@ -4040,6 +3771,13 @@ static void formatUnicodeString(QDebug d, const QString &s)
d << Qt::dec << '"';
}
+static QDebug operator<<(QDebug dbg, const QInputMethodEvent::Attribute &attr)
+{
+ dbg << "[type= " << attr.type << ", start=" << attr.start << ", length=" << attr.length
+ << ", value=" << attr.value << ']';
+ return dbg;
+}
+
static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
{
d << "QInputMethodEvent(";
@@ -4055,15 +3793,15 @@ static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
<< e->replacementLength();
}
- if (const int attributeCount = e->attributes().size()) {
+ const auto attributes = e->attributes();
+ auto it = attributes.cbegin();
+ const auto end = attributes.cend();
+ if (it != end) {
d << ", attributes= {";
- for (int a = 0; a < attributeCount; ++a) {
- const QInputMethodEvent::Attribute &at = e->attributes().at(a);
- if (a)
- d << ',';
- d << "[type= " << at.type << ", start=" << at.start << ", length=" << at.length
- << ", value=" << at.value << ']';
- }
+ d << *it;
+ ++it;
+ for (; it != end; ++it)
+ d << ',' << *it;
d << '}';
}
d << ')';
@@ -4243,23 +3981,20 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e)
d << eventClassName(type) << '(';
QtDebugUtils::formatQEnum(d, type);
- d << ", deviceType=";
- QtDebugUtils::formatQEnum(d, e->deviceType());
- d << ", pointerType=";
- QtDebugUtils::formatQEnum(d, e->pointerType());
- d << ", uniqueId=" << e->pointingDevice()->uniqueId().numericId()
- << ", pos=" << e->position()
- << ", z=" << e->z()
- << ", xTilt=" << e->xTilt()
- << ", yTilt=" << e->yTilt()
- << ", ";
+ d << ' ';
QtDebugUtils::formatQFlags(d, e->buttons());
+ d << " pos=";
+ QtDebugUtils::formatQPoint(d, e->position());
+ d << " z=" << e->z()
+ << " xTilt=" << e->xTilt()
+ << " yTilt=" << e->yTilt();
if (type == QEvent::TabletPress || type == QEvent::TabletMove)
- d << ", pressure=" << e->pressure();
+ d << " pressure=" << e->pressure();
if (e->device()->hasCapability(QInputDevice::Capability::Rotation))
- d << ", rotation=" << e->rotation();
+ d << " rotation=" << e->rotation();
if (e->deviceType() == QInputDevice::DeviceType::Airbrush)
- d << ", tangentialPressure=" << e->tangentialPressure();
+ d << " tangentialPressure=" << e->tangentialPressure();
+ d << " dev=" << e->device() << ')';
}
# endif // QT_CONFIG(tabletevent)
@@ -4277,23 +4012,29 @@ QDebug operator<<(QDebug dbg, const QEventPoint &tp)
{
QDebugStateSaver saver(dbg);
dbg.nospace();
- dbg << "QEventPoint(" << tp.id() << " ts " << tp.timestamp() << " (";
+ dbg << "QEventPoint(id=" << tp.id() << " ts=" << tp.timestamp();
+ dbg << " pos=";
QtDebugUtils::formatQPoint(dbg, tp.position());
- dbg << " scene ";
+ dbg << " scn=";
QtDebugUtils::formatQPoint(dbg, tp.scenePosition());
- dbg << " global ";
+ dbg << " gbl=";
QtDebugUtils::formatQPoint(dbg, tp.globalPosition());
- dbg << ") ";
+ dbg << ' ';
QtDebugUtils::formatQEnum(dbg, tp.state());
- dbg << " pressure " << tp.pressure() << " ellipse ("
- << tp.ellipseDiameters().width() << " x " << tp.ellipseDiameters().height()
- << " angle " << tp.rotation() << ") vel (";
+ if (!qFuzzyIsNull(tp.pressure()) && !qFuzzyCompare(tp.pressure(), 1))
+ dbg << " pressure=" << tp.pressure();
+ if (!tp.ellipseDiameters().isEmpty() || !qFuzzyIsNull(tp.rotation())) {
+ dbg << " ellipse=("
+ << tp.ellipseDiameters().width() << "x" << tp.ellipseDiameters().height()
+ << " \u2221 " << tp.rotation() << ')';
+ }
+ dbg << " vel=";
QtDebugUtils::formatQPoint(dbg, tp.velocity().toPointF());
- dbg << ") start (";
+ dbg << " press=";
QtDebugUtils::formatQPoint(dbg, tp.pressPosition());
- dbg << ") last (";
+ dbg << " last=";
QtDebugUtils::formatQPoint(dbg, tp.lastPosition());
- dbg << ") delta (";
+ dbg << " \u0394 ";
QtDebugUtils::formatQPoint(dbg, tp.position() - tp.lastPosition());
dbg << ')';
return dbg;
@@ -4309,12 +4050,10 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
}
// More useful event output could be added here
const QEvent::Type type = e->type();
+ bool isMouse = false;
switch (type) {
case QEvent::Expose:
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- dbg << "QExposeEvent(" << static_cast<const QExposeEvent *>(e)->region() << ')';
-QT_WARNING_POP
+ dbg << "QExposeEvent()";
break;
case QEvent::Paint:
dbg << "QPaintEvent(" << static_cast<const QPaintEvent *>(e)->region() << ')';
@@ -4327,26 +4066,42 @@ QT_WARNING_POP
case QEvent::NonClientAreaMouseMove:
case QEvent::NonClientAreaMouseButtonRelease:
case QEvent::NonClientAreaMouseButtonDblClick:
+ isMouse = true;
+ Q_FALLTHROUGH();
+ case QEvent::HoverEnter:
+ case QEvent::HoverMove:
+ case QEvent::HoverLeave:
{
- const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
- const Qt::MouseButton button = me->button();
- const Qt::MouseButtons buttons = me->buttons();
- dbg << "QMouseEvent(";
+ const QSinglePointEvent *spe = static_cast<const QSinglePointEvent*>(e);
+ const Qt::MouseButton button = spe->button();
+ const Qt::MouseButtons buttons = spe->buttons();
+ dbg << eventClassName(type) << '(';
QtDebugUtils::formatQEnum(dbg, type);
- if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
- dbg << ", ";
- QtDebugUtils::formatQEnum(dbg, button);
+ if (isMouse) {
+ if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
+ dbg << ' ';
+ QtDebugUtils::formatQEnum(dbg, button);
+ }
+ if (buttons && button != buttons) {
+ dbg << " btns=";
+ QtDebugUtils::formatQFlags(dbg, buttons);
+ }
}
- if (buttons && button != buttons) {
- dbg << ", buttons=";
- QtDebugUtils::formatQFlags(dbg, buttons);
+ QtDebugUtils::formatNonNullQFlags(dbg, ", ", spe->modifiers());
+ dbg << " pos=";
+ QtDebugUtils::formatQPoint(dbg, spe->position());
+ dbg << " scn=";
+ QtDebugUtils::formatQPoint(dbg, spe->scenePosition());
+ dbg << " gbl=";
+ QtDebugUtils::formatQPoint(dbg, spe->globalPosition());
+ dbg << " dev=" << spe->device() << ')';
+ if (isMouse) {
+ auto src = static_cast<const QMouseEvent*>(e)->source();
+ if (src != Qt::MouseEventNotSynthesized) {
+ dbg << " source=";
+ QtDebugUtils::formatQEnum(dbg, src);
+ }
}
- QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers());
- dbg << ", pos=";
- QtDebugUtils::formatQPoint(dbg, me->position());
- dbg << ", globalPos=";
- QtDebugUtils::formatQPoint(dbg, me->globalPosition());
- dbg << ", dev=" << me->device() << ')';
}
break;
# if QT_CONFIG(wheelevent)
@@ -4373,6 +4128,10 @@ QT_WARNING_POP
dbg << ", text=" << ke->text();
if (ke->isAutoRepeat())
dbg << ", autorepeat, count=" << ke->count();
+ if (dbg.verbosity() > QDebug::DefaultVerbosity) {
+ dbg << ", nativeScanCode=" << ke->nativeScanCode();
+ dbg << ", nativeVirtualKey=" << ke->nativeVirtualKey();
+ }
dbg << ')';
}
break;
@@ -4443,9 +4202,15 @@ QT_WARNING_POP
const QNativeGestureEvent *ne = static_cast<const QNativeGestureEvent *>(e);
dbg << "QNativeGestureEvent(";
QtDebugUtils::formatQEnum(dbg, ne->gestureType());
- dbg << ", localPos=";
+ dbg << ", fingerCount=" << ne->fingerCount() << ", localPos=";
QtDebugUtils::formatQPoint(dbg, ne->position());
- dbg << ", value=" << ne->value() << ')';
+ if (!qIsNull(ne->value()))
+ dbg << ", value=" << ne->value();
+ if (!ne->delta().isNull()) {
+ dbg << ", delta=";
+ QtDebugUtils::formatQPoint(dbg, ne->delta());
+ }
+ dbg << ')';
}
break;
# endif // !QT_NO_GESTURES
@@ -4533,6 +4298,8 @@ QT_WARNING_POP
/*!
\fn int QShortcutEvent::shortcutId() const
+ \deprecated
+
Returns the ID of the QShortcut object for which this event was
generated.
@@ -4576,11 +4343,7 @@ bool QWindowStateChangeEvent::isOverride() const
return m_override;
}
-/*! \internal
-*/
-QWindowStateChangeEvent::~QWindowStateChangeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QWindowStateChangeEvent)
/*!
@@ -4635,7 +4398,7 @@ QWindowStateChangeEvent::~QWindowStateChangeEvent()
describes the different states that a touch point may have.
\note The list of points() will never be partial: A touch event will always contain a touch
- point for each existing physical touch contacts targetting the window or widget to which the
+ point for each existing physical touch contacts targeting the window or widget to which the
event is sent. For instance, assuming that all touches target the same window or widget, an
event with a condition of points().count()==2 is guaranteed to imply that the number of
fingers touching the touchscreen or touchpad is exactly two.
@@ -4728,14 +4491,13 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType,
{
for (QEventPoint &point : m_points) {
m_touchPointStates |= point.state();
- QMutableEventPoint::from(point).setDevice(device);
+ QMutableEventPoint::setDevice(point, device);
}
}
+#if QT_DEPRECATED_SINCE(6, 0)
/*!
- \obsolete
- Try to use another constructor, because \a touchPointStates
- can be calculated from the given \a touchPoints.
+ \deprecated [6.0] Use another constructor.
Constructs a QTouchEvent with the given \a eventType, \a device, and
\a touchPoints. The \a touchPointStates and \a modifiers are the current
@@ -4751,14 +4513,11 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType,
m_touchPointStates(touchPointStates)
{
for (QEventPoint &point : m_points)
- QMutableEventPoint::from(point).setDevice(device);
+ QMutableEventPoint::setDevice(point, device);
}
+#endif // QT_DEPRECATED_SINCE(6, 0)
-/*!
- Destroys the QTouchEvent.
-*/
-QTouchEvent::~QTouchEvent()
-{ }
+Q_IMPL_POINTER_EVENT(QTouchEvent)
/*!
Returns true if this event includes at least one newly-pressed touchpoint.
@@ -4798,185 +4557,13 @@ bool QTouchEvent::isEndEvent() const
*/
/*! \fn const QList<QEventPoint> &QTouchEvent::touchPoints() const
- \obsolete
- Deprecated since Qt 6.0. Use points() instead.
+ \deprecated [6.0] Use points() instead.
Returns a reference to the list of touch points contained in the touch event.
\sa QPointerEvent::point(), QPointerEvent::pointCount()
*/
-/*! \class QEventPoint
- \brief The QEventPoint class provides information about a point in a QPointerEvent.
- \since 6.0
- \inmodule QtGui
-*/
-
-/*!
- \enum QEventPoint::State
-
- Specifies the state of this event point.
-
- \value Unknown
- Unknown state.
-
- \value Stationary
- The event point did not move.
-
- \value Pressed
- The touch point or button is pressed.
-
- \value Updated
- The event point was updated.
-
- \value Released
- The touch point or button was released.
-*/
-
-/*! \fn int QEventPoint::id() const
-
- Returns the ID number of this event point.
-
- \note Do not assume that ID numbers start at zero or that they are
- sequential. Such an assumption is often false due to the way
- the underlying drivers work.
-*/
-
-/*! \fn QPointingDeviceUniqueId QEventPoint::uniqueId() const
-
- Returns the unique ID of this point or token, if any.
-
- It is often invalid (see \l {QPointingDeviceUniqueId::isValid()} {isValid()}),
- because touchscreens cannot uniquely identify fingers.
-
- When it comes from a QTabletEvent, it identifies the serial number of the
- stylus in use.
-
- It may identify a specific token (fiducial object) when the TUIO driver is
- in use with a touchscreen that supports them.
-*/
-
-/*! \fn QEventPoint::State QEventPoint::state() const
- Returns the current state of this point.
-*/
-
-/*! \fn QPointF QEventPoint::position() const
-
- Returns the position of this point, relative to the widget
- or item that received the event.
-*/
-
-/*! \fn QPointF QEventPoint::pos() const
- \obsolete
- Deprecated since Qt 6.0. Use position() instead.
-
- Returns the position of this point, relative to the widget
- or item that received the event.
-*/
-
-/*! \fn QPointF QEventPoint::scenePosition() const
- Returns the position of this point relative to the window or scene.
-
- The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(),
- in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(),
- or the window position in widget applications.
-
- \sa scenePressPosition(), position(), globalPosition()
-*/
-
-/*! \fn QPointF QEventPoint::globalPosition() const
- Returns the position of this point on the screen or virtual desktop.
-
- \sa globalPressPosition(), position(), scenePosition()
-*/
-
-/*! \fn QPointF QEventPoint::pressPosition() const
- Returns the position at which this point was pressed, relative to the
- widget or item that received the event.
-
- \sa position()
-*/
-
-/*! \fn QPointF QEventPoint::scenePressPosition() const
- Returns the scene position at which this point was pressed.
-
- The scene position is the position relative to QQuickWindow if handled in QQuickItem::event(),
- in QGraphicsScene coordinates if handled by an override of QGraphicsItem::touchEvent(),
- or the window position in widget applications.
-
- \sa scenePosition(), pressPosition(), globalPressPosition()
-*/
-
-/*! \fn QPointF QEventPoint::globalPressPosition() const
- Returns the position at which this point was pressed on the screen or virtual desktop.
-
- \sa globalPosition(), pressPosition(), scenePressPosition()
-*/
-
-/*! \fn QPointF QEventPoint::lastPosition() const
- Returns the position of this point from the previous press or move event,
- relative to the widget or QGraphicsItem that received the event.
-
- \sa position(), pressPosition()
-*/
-
-/*! \fn QPointF QEventPoint::sceneLastPosition() const
- Returns the scene position of this point from the previous press or move event.
-
- The scene position is the position in QGraphicsScene coordinates
- if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
- reimplementation, and identical to the screen position for
- widgets.
-
- \sa scenePosition(), scenePressPosition()
-*/
-
-/*! \fn qreal QEventPoint::pressure() const
- Returns the pressure of this point. The return value is in
- the range \c 0.0 to \c 1.0.
-*/
-
-/*! \fn qreal QEventPoint::rotation() const
-
- Returns the angular orientation of this point. The return value is in degrees,
- where zero (the default) indicates the finger, token or stylus is pointing upwards,
- a negative angle means it's rotated to the left, and a positive angle means
- it's rotated to the right. Most touchscreens do not detect rotation, so
- zero is the most common value.
-*/
-
-/*! \fn QSizeF QEventPoint::ellipseDiameters() const
-
- Returns the width and height of the bounding ellipse of the touch point.
- The return value is in logical pixels. Most touchscreens do not detect the
- shape of the contact point, and no mice or tablet devices can detect it,
- so a null size is the most common value. On some touchscreens the diameters
- may be nonzero and always equal (the ellipse is approximated as a circle).
-*/
-
-/*!
- \fn QVector2D QEventPoint::velocity() const
- Returns a velocity vector, in units of pixels per second, in the coordinate
- system of the screen or desktop.
-
- \note If the device's capabilities include QInputDevice::Velocity, it means
- velocity comes from the operating system (perhaps the touch hardware or
- driver provides it). But usually the \c Velocity capability is not set,
- indicating that the velocity is calculated by Qt, using a simple Kalman
- filter to provide a smoothed average velocity rather than an instantaneous
- value. Effectively it tells how fast and in what direction the user has
- been dragging this point over the last few events, with the most recent
- event having the strongest influence.
-
- \sa QInputDevice::capabilities(), QInputEvent::device()
-*/
-
-/*! \fn ulong QEventPoint::timestamp() const
- Returns the most recent time at which this point was included in a QPointerEvent.
-
- \sa QPointerEvent::timestamp()
-*/
-
/*!
\class QScrollPrepareEvent
\since 4.8
@@ -5004,47 +4591,30 @@ QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
{
}
-/*!
- Destroys QScrollEvent.
-*/
-QScrollPrepareEvent::~QScrollPrepareEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QScrollPrepareEvent)
/*!
+ \fn QPointF QScrollPrepareEvent::startPos() const
+
Returns the position of the touch or mouse event that started the scrolling.
*/
-QPointF QScrollPrepareEvent::startPos() const
-{
- return m_startPos;
-}
/*!
+ \fn QSizeF QScrollPrepareEvent::viewportSize() const
Returns size of the area that is to be scrolled as set by setViewportSize
\sa setViewportSize()
*/
-QSizeF QScrollPrepareEvent::viewportSize() const
-{
- return m_viewportSize;
-}
/*!
+ \fn QRectF QScrollPrepareEvent::contentPosRange() const
Returns the range of coordinates for the content as set by setContentPosRange().
*/
-QRectF QScrollPrepareEvent::contentPosRange() const
-{
- return m_contentPosRange;
-}
/*!
+ \fn QPointF QScrollPrepareEvent::contentPos() const
Returns the current position of the content as set by setContentPos.
*/
-QPointF QScrollPrepareEvent::contentPos() const
-{
- return m_contentPos;
-}
-
/*!
Sets the size of the area that is to be scrolled to \a size.
@@ -5119,33 +4689,26 @@ QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDi
{
}
-/*!
- Destroys QScrollEvent.
-*/
-QScrollEvent::~QScrollEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QScrollEvent)
/*!
+ \fn QPointF QScrollEvent::contentPos() const
+
Returns the new scroll position.
*/
-QPointF QScrollEvent::contentPos() const
-{
- return m_contentPos;
-}
/*!
+ \fn QPointF QScrollEvent::overshootDistance() const
+
Returns the new overshoot distance.
See QScroller for an explanation of the term overshoot.
\sa QScroller
*/
-QPointF QScrollEvent::overshootDistance() const
-{
- return m_overshoot;
-}
/*!
+ \fn QScrollEvent::ScrollState QScrollEvent::scrollState() const
+
Returns the current scroll state as a combination of ScrollStateFlag values.
ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
@@ -5153,10 +4716,6 @@ QPointF QScrollEvent::overshootDistance() const
A widget could for example revert selections when scrolling is started and stopped.
*/
-QScrollEvent::ScrollState QScrollEvent::scrollState() const
-{
- return m_state;
-}
/*!
Creates a new QScreenOrientationChangeEvent
@@ -5167,28 +4726,19 @@ QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt
{
}
-/*!
- Destroys QScreenOrientationChangeEvent.
-*/
-QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QScreenOrientationChangeEvent)
/*!
+ \fn QScreen *QScreenOrientationChangeEvent::screen() const
+
Returns the screen whose orientation changed.
*/
-QScreen *QScreenOrientationChangeEvent::screen() const
-{
- return m_screen;
-}
/*!
+ \fn Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
+
Returns the orientation of the screen.
*/
-Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
-{
- return m_orientation;
-}
/*!
Creates a new QApplicationStateChangeEvent.
@@ -5199,116 +4749,73 @@ QApplicationStateChangeEvent::QApplicationStateChangeEvent(Qt::ApplicationState
{
}
+Q_IMPL_EVENT_COMMON(QApplicationStateChangeEvent)
+
/*!
- Returns the state of the application.
-*/
-Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const
-{
- return m_applicationState;
-}
+ \fn Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const
-/*! \internal
- Add the given \a point.
+ Returns the state of the application.
*/
-void QMutableTouchEvent::addPoint(const QEventPoint &point)
-{
- m_points.append(point);
- auto &added = m_points.last();
- if (!added.device())
- QMutableEventPoint::from(added).setDevice(pointingDevice());
- m_touchPointStates |= point.state();
-}
/*!
- \class QPointingDeviceUniqueId
- \since 5.8
- \ingroup events
+ \class QChildWindowEvent
\inmodule QtGui
+ \since 6.7
+ \brief The QChildWindowEvent class contains event parameters for
+ child window changes.
- \brief QPointingDeviceUniqueId identifies a unique object, such as a tagged token
- or stylus, which is used with a pointing device.
-
- QPointingDeviceUniqueIds can be compared for equality, and can be used as keys in a QHash.
- You get access to the numerical ID via numericId(), if the device supports such IDs.
- For future extensions, though, you should not use that function, but compare objects
- of this type using the equality operator.
+ \ingroup events
- This class is a thin wrapper around an integer ID. You pass it into and out of
- functions by value.
+ Child window events are sent to windows when children are
+ added or removed.
- \sa QEventPoint
+ In both cases you can only rely on the child being a QWindow
+ — not any subclass thereof. This is because in the
+ QEvent::ChildWindowAdded case the subclass is not yet fully
+ constructed, and in the QEvent::ChildWindowRemoved case it
+ might have already been destructed.
*/
/*!
- \fn QPointingDeviceUniqueId::QPointingDeviceUniqueId()
- Constructs an invalid unique pointer ID.
-*/
+ Constructs a child window event object of a particular \a type
+ for the \a childWindow.
-/*!
- Constructs a unique pointer ID from numeric ID \a id.
+ \a type can be QEvent::ChildWindowAdded or QEvent::ChildWindowRemoved.
+
+ \sa child()
*/
-QPointingDeviceUniqueId QPointingDeviceUniqueId::fromNumericId(qint64 id)
+QChildWindowEvent::QChildWindowEvent(Type type, QWindow *childWindow)
+ : QEvent(type), c(childWindow)
{
- QPointingDeviceUniqueId result;
- result.m_numericId = id;
- return result;
}
-/*!
- \fn bool QPointingDeviceUniqueId::isValid() const
-
- Returns whether this unique pointer ID is valid, that is, it represents an actual
- pointer.
-*/
+Q_IMPL_EVENT_COMMON(QChildWindowEvent)
/*!
- \property QPointingDeviceUniqueId::numericId
- \brief the numeric unique ID of the token represented by a touchpoint
-
- If the device provides a numeric ID, isValid() returns true, and this
- property provides the numeric ID;
- otherwise it is -1.
-
- You should not use the value of this property in portable code, but
- instead rely on equality to identify pointers.
+ \fn QWindow *QChildWindowEvent::child() const
- \sa isValid()
+ Returns the child window that was added or removed.
*/
-qint64 QPointingDeviceUniqueId::numericId() const noexcept
-{
- return m_numericId;
-}
-/*!
- \relates QPointingDeviceUniqueId
- \since 5.8
+QMutableTouchEvent::~QMutableTouchEvent()
+ = default;
- Returns whether the two unique pointer IDs \a lhs and \a rhs identify the same pointer
- (\c true) or not (\c false).
+/*! \internal
+ Add the given \a point.
*/
-bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept
+void QMutableTouchEvent::addPoint(const QEventPoint &point)
{
- return lhs.numericId() == rhs.numericId();
+ m_points.append(point);
+ auto &added = m_points.last();
+ if (!added.device())
+ QMutableEventPoint::setDevice(added, pointingDevice());
+ m_touchPointStates |= point.state();
}
-/*!
- \fn bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs)
- \relates QPointingDeviceUniqueId
- \since 5.8
-
- Returns whether the two unique pointer IDs \a lhs and \a rhs identify different pointers
- (\c true) or not (\c false).
-*/
-/*!
- \relates QPointingDeviceUniqueId
- \since 5.8
-
- Returns the hash value for \a key, using \a seed to seed the calculation.
-*/
-size_t qHash(QPointingDeviceUniqueId key, size_t seed) noexcept
-{
- return qHash(key.numericId(), seed);
-}
+QMutableSinglePointEvent::~QMutableSinglePointEvent()
+ = default;
QT_END_NAMESPACE
+
+#include "moc_qevent.cpp"