QTimerEvent: port to Qt::TimerId
[ChangeLog][QtCore][QTimerEvent] Added constructor taking a Qt::TimerId. Also added a getter for Qt::TimerId. [ChangeLog][Potentially Source-Incompatible Changes] The protected (and undocumented) QTimerEvent::id member variable has been renamed to m_id to allow for the addition of an id() getter that returns a Qt::TimerId. Task-number: QTBUG-128144 Pick-to: 6.8 Change-Id: Ia156f11e9e9347b6bf61b36e40da3ad551d23407 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
81d31d2760
commit
29b98eabf0
@ -533,9 +533,21 @@ int QEvent::registerEventType(int hint) noexcept
|
||||
\a timerId.
|
||||
*/
|
||||
QTimerEvent::QTimerEvent(int timerId)
|
||||
: QEvent(Timer), id(timerId)
|
||||
: QTimerEvent(Qt::TimerId{timerId})
|
||||
{}
|
||||
|
||||
/*!
|
||||
\since 6.8
|
||||
|
||||
Constructs a timer event object with the timer identifier set to
|
||||
\a timerId.
|
||||
*/
|
||||
QTimerEvent::QTimerEvent(Qt::TimerId timerId)
|
||||
: QEvent(Timer), m_id(timerId)
|
||||
{
|
||||
static_assert(sizeof(Qt::TimerId) == sizeof(int));
|
||||
}
|
||||
|
||||
Q_IMPL_EVENT_COMMON(QTimerEvent)
|
||||
|
||||
/*!
|
||||
@ -545,6 +557,15 @@ Q_IMPL_EVENT_COMMON(QTimerEvent)
|
||||
as returned from QObject::startTimer().
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Qt::TimerId QTimerEvent::id() const
|
||||
\since 6.8
|
||||
|
||||
Returns the Qt::TimerId of the timer associated with this event, which
|
||||
is the same identifier returned by QObject::startTimer() cast to
|
||||
Qt::TimerId.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QChildEvent
|
||||
\inmodule QtCore
|
||||
|
@ -367,10 +367,13 @@ class Q_CORE_EXPORT QTimerEvent : public QEvent
|
||||
Q_DECL_EVENT_COMMON(QTimerEvent)
|
||||
public:
|
||||
explicit QTimerEvent(int timerId);
|
||||
int timerId() const { return id; }
|
||||
explicit QTimerEvent(Qt::TimerId timerId);
|
||||
|
||||
int timerId() const { return qToUnderlying(id()); }
|
||||
Qt::TimerId id() const { return m_id; }
|
||||
|
||||
protected:
|
||||
int id;
|
||||
Qt::TimerId m_id;
|
||||
};
|
||||
|
||||
class QObject;
|
||||
|
Loading…
x
Reference in New Issue
Block a user