QFutureWatcher docs mismatch
-
Hi! Qt docs says:
QFutureWatcher<void> is specialized to not contain any of the result fetching functions. Any QFuture<T> can be watched by a QFutureWatcher<void> as well. This is useful if only status or progress information is needed; not the actual result data.
But with this example
#include <QtConcurrent/qtconcurrentrun.h> #include <qfuturewatcher.h> ... void perform() { auto future = QtConcurrent::run([](){ return 5; }); QFutureWatcher<void> watcher; watcher.setFuture(future); }
It will report the error about T mismatch:
No viable conversion from ‘QFuture<int>’ to ‘const QFuture<void>’
How to achieve the ability to watch any QFuture<T> with QFutureWatcher<void> ? I need only progress tracking, don't care about result value. I understand that if i will change to QFutureWatcher<int> everything will work.
Thanks in advance. -
@vinadenenko
Discussed at https://lists.qt-project.org/pipermail/interest/2022-September/038483.html as a Qt6 change/issue.
I believe the solution there is "The recommended approach is to explicitly use a corresponding QFuture<void> constructor"?
Yes, see https://doc.qt.io/qt-6/qtcore-changes-qt6.html#implicit-conversions-between-qfuture-and-other-types in the docs. -