summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreevent.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-11-04 22:10:35 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-11-07 06:24:38 +0100
commit9a1a15b42fb526ad4f80944afb7761bfff1b5c9d (patch)
tree058dd55dff01b3d6a429ff863132e33c05d019be /src/corelib/kernel/qcoreevent.cpp
parentbdec189ecbc2cabbfa803a571b49533f190f053d (diff)
Introduce QEvent::isSinglePointEvent()
This makes high-level event dispatching easier: for example we often need to cast an event to access getters like button() and buttons(). We can so far assume that any QPointerEvent that is not a QTouchEvent is a QSinglePointEvent; but more explicit type-checking looks safer. Implemented in a similar way as c7f727996909338c3689396160f3060480521846. Change-Id: I980d759e2a7538b6b30fd3bdc3be0c351ec6c246 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreevent.cpp')
-rw-r--r--src/corelib/kernel/qcoreevent.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 6fdc2a94af..af89524dc4 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -294,7 +294,8 @@ QT_BEGIN_NAMESPACE
Contructs an event object of type \a type.
*/
QEvent::QEvent(Type type)
- : d(nullptr), t(type), posted(false), spont(false), m_accept(true), m_inputEvent(false), m_pointerEvent(false)
+ : d(nullptr), t(type), posted(false), spont(false), m_accept(true),
+ m_inputEvent(false), m_pointerEvent(false), m_singlePointEvent(false)
{
Q_TRACE(QEvent_ctor, this, t);
}
@@ -305,7 +306,8 @@ QEvent::QEvent(Type type)
*/
QEvent::QEvent(const QEvent &other)
: d(other.d), t(other.t), posted(other.posted), spont(other.spont),
- m_accept(other.m_accept), m_inputEvent(other.m_inputEvent), m_pointerEvent(other.m_pointerEvent)
+ m_accept(other.m_accept), m_inputEvent(other.m_inputEvent),
+ m_pointerEvent(other.m_pointerEvent), m_singlePointEvent(other.m_singlePointEvent)
{
Q_TRACE(QEvent_ctor, this, t);
// if QEventPrivate becomes available, make sure to implement a
@@ -332,6 +334,15 @@ QEvent::QEvent(const QEvent &other)
/*!
\internal
+ \since 6.0
+ \fn QEvent::QEvent(Type type, QEvent::SinglePointEventTag)
+
+ Constructs an event object of type \a type, setting the singlePointEvent,
+ pointerEvent and inputEvent flags to \c true.
+*/
+
+/*!
+ \internal
Attempts to copy the \a other event.
Copying events is a bad idea, yet some Qt 4 code does it (notably,
@@ -438,6 +449,13 @@ QEvent::~QEvent()
subclasses.
*/
+/*!
+ \fn bool QEvent::isSinglePointEvent() const
+ \since 6.0
+
+ Returns \c true if the event object is a subclass of QSinglePointEvent.
+*/
+
namespace {
template <size_t N>
struct QBasicAtomicBitField {