Hi Sean,

I'm not a QtConcurrent expert, but it looks like the reason for the error 
message is that an implicit conversion between QFuture<void> and QFuture<T> was 
removed in Qt 6. The recommended approach is to explicitly use a corresponding 
QFuture<void> constructor.
See the details in the documentation: 

Best regards,

From: Interest <interest-boun...@qt-project.org> on behalf of Sean Murphy via 
Interest <interest@qt-project.org>
Sent: Wednesday, September 28, 2022 4:15 PM
To: interest@qt-project.org <interest@qt-project.org>
Subject: [Interest] Question about QFutureWatcher<void> monitoring a QFuture<T>

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.
Interest mailing list
Interest mailing list

Reply via email to