diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-07-03 11:06:37 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-17 21:54:34 +0200 |
commit | d1111632e29124531d5b4512e0492314caaae396 (patch) | |
tree | 15bdf8c7f348b236a90f5ef59ceec4ce91ee4af1 /src/corelib/kernel/qcoreevent.cpp | |
parent | 81159cf3f7c47dbab4c781f3b4ffa9e0a202b1dc (diff) |
Introduce QEvent::isInputEvent
This makes it easier to reliably maintain input-event related states
in widgets, in particluar the state of keyboard modifiers. Instead of
testing for all possible event types, code can just test the flag before
safely static_cast'ing to QInputEvent to access the modifiers.
Simplify the code in QAbstractItemView accordingly.
Task-number: QTBUG-73829
Change-Id: Idc7c08e2f3f1e8844f5c6693c195153038ee6490
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreevent.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreevent.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index e3326f00d7..34712be47a 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -295,7 +295,7 @@ 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) + : d(nullptr), t(type), posted(false), spont(false), m_accept(true), m_inputEvent(false) { Q_TRACE(QEvent_ctor, this, t); } @@ -319,6 +319,14 @@ QEvent::QEvent(const QEvent &other) /*! \internal + \since 6.0 + \fn QEvent::QEvent(Type type, QEvent::InputEventTag) + + Constructs an event object of type \a type, setting the inputEvent flag to true. +*/ + +/*! + \internal Attempts to copy the \a other event. Copying events is a bad idea, yet some Qt 4 code does it (notably, @@ -407,6 +415,14 @@ QEvent::~QEvent() The return value of this function is not defined for paint events. */ +/*! + \fn bool QEvent::isInputEvent() const + \since 6.0 + + Returns \c true if the event object is a QInputEvent or one of its + subclasses. +*/ + namespace { template <size_t N> struct QBasicAtomicBitField { |