diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index e3bbac7a3c6..c01e7b80ed3 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -124,11 +124,10 @@ MyObject::MyObject(QObject *parent) void MyObject::timerEvent(QTimerEvent *event) { - qDebug() << "Timer ID:" << event->timerId(); + qDebug() << "Timer ID:" << event->id(); } //! [8] - //! [10] QPushButton *button = parentWidget->findChild("button1"); //! [10] @@ -474,11 +473,8 @@ someQObject->blockSignals(wasBlocked); //! [invalid-timer-id] QObject *obj; ... - int id = obj->startTimer(100ms); - if (id > Qt::TimerId::Invalid) - // The timer has been started successfully - - if (id > 0) // Equivalent, albeit less readable + const auto id = Qt::TimerId{obj->startTimer(100ms)}; + if (id != Qt::TimerId::Invalid) // The timer has been started successfully //! [invalid-timer-id] } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4426e5f6c90..574b70e74e7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1837,7 +1837,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType) event parameter class when a timer event occurs. Reimplement this function to get timer events. - If multiple timers are running, the QTimerEvent::timerId() can be + If multiple timers are running, the QTimerEvent::id() method can be used to find out which timer was activated. Example: