Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFutureWatcher docs mismatch
Forum Updated to NodeBB v4.3 + New Features

QFutureWatcher docs mismatch

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 181 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vinadenenko
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • V vinadenenko

      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.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @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.

      V 1 Reply Last reply
      1
      • JonBJ JonB

        @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.

        V Offline
        V Offline
        vinadenenko
        wrote on last edited by
        #3

        @JonB Thanks a lot, closing.

        1 Reply Last reply
        0
        • V vinadenenko has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved