QTimer: fix API docs of callOnTimeOut overload

It actually takes one parameter, because in this overload the connection
type can't be specified, for example:
QTimer timer;
timer.callOnTimeout([]() { qDebug() << "slot"; });

The call chain is:
QObject::connect(timer, &QTimer::timeout, functor);
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 &&slot)
connect(sender, signal, sender, std::forward<Func2>(slot), Qt::DirectConnection);

the connection type is always DirectConnection.

Spotted by Giuseppe in code review.

Pick-to: 6.6 6.5 5.15
Change-Id: Ia8bbd91e98a357244cbfae4e3ed63d4c73038fa2
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Ahmad Samir 2023-07-21 20:24:09 +03:00
parent 9bc43ba1c6
commit 794e0d1ac6
2 changed files with 8 additions and 6 deletions

View File

@ -505,14 +505,16 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
*/ */
/*! /*!
\fn template <typename Functor> QMetaObject::Connection QTimer::callOnTimeout(Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection) \fn template <typename Functor> QMetaObject::Connection QTimer::callOnTimeout(Functor &&slot)
\since 5.12 \since 5.12
Creates a connection of type \a connectionType from the timeout() signal Creates a connection from the timer's timeout() signal to \a slot.
to \a slot, and returns a handle to the connection. Returns a handle to the connection.
This method is provided for convenience. This method is provided for convenience. It's equivalent to calling:
It's equivalent to calling \c {QObject::connect(timer, &QTimer::timeout, timer, slot, connectionType)}. \code
QObject::connect(timer, &QTimer::timeout, timer, slot, Qt::DirectConnection);
\endcode
\sa QObject::connect(), timeout() \sa QObject::connect(), timeout()
*/ */

View File

@ -89,7 +89,7 @@ public:
#ifdef Q_QDOC #ifdef Q_QDOC
template <typename Functor> template <typename Functor>
QMetaObject::Connection callOnTimeout(Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection); QMetaObject::Connection callOnTimeout(Functor &&slot);
template <typename Functor> template <typename Functor>
QMetaObject::Connection callOnTimeout(const QObject *context, Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection); QMetaObject::Connection callOnTimeout(const QObject *context, Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection);
#else #else