Doc: fix warnings in QTimer

Amends recent changes that added std::chrono support by making
the duration type of QTimer::singleShot a template parameter.

Change-Id: If3b5f0ad99304cb292412bb8467ba6852e47654f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Volker Hilsheimer 2023-05-03 15:09:32 +02:00
parent 178c123a6f
commit 1af36eb230
2 changed files with 22 additions and 35 deletions

View File

@ -441,10 +441,10 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
} }
} }
/*! \fn template<typename Functor> void QTimer::singleShot(int msec, const QObject *context, Functor &&functor) /*! \fn template<typename Duration, typename Functor> void QTimer::singleShot(Duration msec, const QObject *context, Functor &&functor)
\fn template<typename Functor> void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor &&functor) \fn template<typename Duration, typename Functor> void QTimer::singleShot(Duration msec, Qt::TimerType timerType, const QObject *context, Functor &&functor)
\fn template<typename Functor> void QTimer::singleShot(int msec, Functor &&functor) \fn template<typename Duration, typename Functor> void QTimer::singleShot(Duration msec, Functor &&functor)
\fn template<typename Functor> void QTimer::singleShot(int msec, Qt::TimerType timerType, Functor &&functor) \fn template<typename Duration, typename Functor> void QTimer::singleShot(Duration msec, Qt::TimerType timerType, Functor &&functor)
\since 5.4 \since 5.4
\reentrant \reentrant
@ -462,6 +462,8 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
If \a functor is a member If \a functor is a member
function of \a context, then the function will be called on the object. function of \a context, then the function will be called on the object.
The \a msec parameter can be an \c int or a \c std::chrono::milliseconds value.
\sa start() \sa start()
*/ */
@ -503,9 +505,8 @@ 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, Qt::ConnectionType connectionType = Qt::AutoConnection)
\since 5.12 \since 5.12
\overload
Creates a connection of type \a connectionType from the timeout() signal Creates a connection of type \a connectionType from the timeout() signal
to \a slot, and returns a handle to the connection. to \a slot, and returns a handle to the connection.
@ -517,7 +518,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
*/ */
/*! /*!
\fn template <typename Functor> QMetaObject::Connection QTimer::callOnTimeout(const QObject *context, Functor slot, Qt::ConnectionType connectionType = Qt::AutoConnection) \fn template <typename Functor> QMetaObject::Connection QTimer::callOnTimeout(const QObject *context, Functor &&slot, Qt::ConnectionType connectionType = Qt::AutoConnection)
\since 5.12 \since 5.12
\overload callOnTimeout() \overload callOnTimeout()
@ -530,20 +531,6 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
\sa QObject::connect(), timeout() \sa QObject::connect(), timeout()
*/ */
/*!
\fn template <typename MemberFunction> QMetaObject::Connection QTimer::callOnTimeout(const QObject *receiver, MemberFunction *slot, Qt::ConnectionType connectionType = Qt::AutoConnection)
\since 5.12
\overload callOnTimeout()
Creates a connection from the timeout() signal to the \a slot in the \a receiver object. Returns
a handle to the connection.
This method is provided for convenience. It's equivalent to calling
\c {QObject::connect(timer, &QTimer::timeout, receiver, slot, connectionType)}.
\sa QObject::connect(), timeout()
*/
/*! /*!
\fn void QTimer::start(std::chrono::milliseconds msec) \fn void QTimer::start(std::chrono::milliseconds msec)
\since 5.8 \since 5.8

View File

@ -50,41 +50,41 @@ public:
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member); static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
// singleShot with context // singleShot with context
template <typename Duration, typename Func1> template <typename Duration, typename Functor>
static inline void singleShot(Duration interval, static inline void singleShot(Duration interval,
#ifdef Q_QDOC #ifdef Q_QDOC
const QObject *receiver, const QObject *receiver,
#else #else
const typename QtPrivate::ContextTypeForFunctor<Func1>::ContextType *receiver, const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *receiver,
#endif #endif
Func1 &&slot) Functor &&slot)
{ {
singleShot(interval, defaultTypeFor(interval), receiver, std::forward<Func1>(slot)); singleShot(interval, defaultTypeFor(interval), receiver, std::forward<Functor>(slot));
} }
template <typename Duration, typename Func1> template <typename Duration, typename Functor>
static inline void singleShot(Duration interval, Qt::TimerType timerType, static inline void singleShot(Duration interval, Qt::TimerType timerType,
#ifdef Q_QDOC #ifdef Q_QDOC
const QObject *receiver, const QObject *receiver,
#else #else
const typename QtPrivate::ContextTypeForFunctor<Func1>::ContextType *receiver, const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *receiver,
#endif #endif
Func1 &&slot) Functor &&slot)
{ {
using Prototype = void(*)(); using Prototype = void(*)();
singleShotImpl(interval, timerType, receiver, singleShotImpl(interval, timerType, receiver,
QtPrivate::makeSlotObject<Prototype>(std::forward<Func1>(slot))); QtPrivate::makeSlotObject<Prototype>(std::forward<Functor>(slot)));
} }
// singleShot without context // singleShot without context
template <typename Duration, typename Func1> template <typename Duration, typename Functor>
static inline void singleShot(Duration interval, Func1 &&slot) static inline void singleShot(Duration interval, Functor &&slot)
{ {
singleShot(interval, defaultTypeFor(interval), nullptr, std::forward<Func1>(slot)); singleShot(interval, defaultTypeFor(interval), nullptr, std::forward<Functor>(slot));
} }
template <typename Duration, typename Func1> template <typename Duration, typename Functor>
static inline void singleShot(Duration interval, Qt::TimerType timerType, Func1 &&slot) static inline void singleShot(Duration interval, Qt::TimerType timerType, Functor &&slot)
{ {
singleShot(interval, timerType, nullptr, std::forward<Func1>(slot)); singleShot(interval, timerType, nullptr, std::forward<Functor>(slot));
} }
#ifdef Q_QDOC #ifdef Q_QDOC