QObject: use Qt::TimerId in the code snippets and API docs

Mention QTimerEvent::id(), which returns Qt::TimerId, instead of
QTimerEvent::timerId() which returns int in the API docs.

Task-number: QTBUG-128144
Change-Id: Id19aebd044fbd734872e5580efcb3842eb42b2b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7595c21be86f247dd419d08d7d26327fe2d7a736)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ahmad Samir 2024-08-30 22:30:17 +03:00 committed by Qt Cherry-pick Bot
parent 0bd6bbedea
commit 91ed5ddff5
2 changed files with 4 additions and 8 deletions

View File

@ -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<QPushButton *>("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]
}

View File

@ -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: