Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.5.1, 5.11.1
-
None
-
491e427bb2d3cafccbb26d2ca3b7e128d786a564
Description
The documentation of QTimer::singleShot() states that the context/receiver should be a const pointer to QObject. This is consistent with e.g. QObject::connect().
However, in reality the overloads taking a functor require a non-const pointer, which is both inconvenient and against the documentation and standard practice.
Looking at qtimer.h, I see this:
// singleShot to a functor or function pointer (with context) template <typename Duration, typename Func1> static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction && !std::is_same<const char*, Func1>::value, void>::type singleShot(Duration interval, QObject *context, Func1 slot) { singleShot(interval, defaultTypeFor(interval), context, std::move(slot)); }
So this seems to be a bug in the method signature/implementation.
Attachments
Issue Links
- replaces
-
QTBUG-61858 QTimer::singleShot: const mismatch between docs and reality
-
- Closed
-
For Gerrit Dashboard: QTBUG-69800 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
236191,2 | QTimer: Add const to some singleShot methods | dev | qt/qtbase | Status: MERGED | +2 | 0 |