[Interest] Question about QFutureWatcher<void> monitoring a QFuture<T>

Sean Murphy Sean.M.Murphy at us.kbr.com
Wed Sep 28 16:15:29 CEST 2022

In the Qt Docs, at the bottom of QFutureWatcher's Detailed
Description section there's this statement:
  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.

That statement fits what I'm trying to do - I only need the
status/progress information. So I attempt the lines:
  QFutureWatcher<void> watcher;
  watcher.setFuture(QtConcurrent::mappedReduced(list, mapped, reduce));

This fails to compile with the error message:
  No viable conversion from 'QFuture<int>' to 'const QFuture<void>'
Where my mapped() function has the form
  U function(const T &t);
And my reduce() function has the form
  void function(int &result, const U &intermediate)

If I explicitly cast the mappedReduced() return value to a QFuture<void>:
             QtConcurrent::mappedReduced(list, mapped, reduce)));

It compiles and seems to run fine, but I just wanted to double
check this was intended behavior, or if there was a better way
to do it? From the line in the docs, I assumed that the original
assignment was fine and I wouldn't need to explicitly cast.


This e-mail, including any attached files, may contain confidential information, privileged information and/or trade secrets for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

More information about the Interest mailing list