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. "...back to the future ..."
Forum Updated to NodeBB v4.3 + New Features

"...back to the future ..."

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 641 Views 3 Watching
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    When I used this call

    // Start the computation.
    QFuture<int> future = QtConcurrent::run(...);
    watcher.setFuture(future);
    

    "future" contained # of devices detected by the function run by QtConcurrent.
    How do I retrieve this value (int) returned by the function when I "bypass " QTFuturre using this call

    watcher->setFuture(QtConcurrent::run(                                                                                                                                                                                                                 std::bind(                                                                                                                                                                                                                                                                                                                   hci_inquiry,                                                                                                                                                                                                                                                                                                                    dev_id,                                                                                                                                                                                                                                                                                                                    len,                                                                                                                                                                                                                                                                                                                    max_rsp,                                                                                                                                                                                                                                                                                                               lap,    ,                                                                                                                                                                                                                                                                                                                    &ii,                                                                                                                                                                                                                                                                                                                    flags)                                                                                                                                                                                                                                                                                                                    ));
    

    QTFutureWatcher have access to "indexes" but I really do not get what they are.

    Now "watcher" is defined this way

    watcher = new QFutureWatcher<int>;

    so all these are templates and I am lost using them correctly.
    I would appreciated reply with code.

    J.HilkJ 1 Reply Last reply
    0
    • A Anonymous_Banned275

      When I used this call

      // Start the computation.
      QFuture<int> future = QtConcurrent::run(...);
      watcher.setFuture(future);
      

      "future" contained # of devices detected by the function run by QtConcurrent.
      How do I retrieve this value (int) returned by the function when I "bypass " QTFuturre using this call

      watcher->setFuture(QtConcurrent::run(                                                                                                                                                                                                                 std::bind(                                                                                                                                                                                                                                                                                                                   hci_inquiry,                                                                                                                                                                                                                                                                                                                    dev_id,                                                                                                                                                                                                                                                                                                                    len,                                                                                                                                                                                                                                                                                                                    max_rsp,                                                                                                                                                                                                                                                                                                               lap,    ,                                                                                                                                                                                                                                                                                                                    &ii,                                                                                                                                                                                                                                                                                                                    flags)                                                                                                                                                                                                                                                                                                                    ));
      

      QTFutureWatcher have access to "indexes" but I really do not get what they are.

      Now "watcher" is defined this way

      watcher = new QFutureWatcher<int>;

      so all these are templates and I am lost using them correctly.
      I would appreciated reply with code.

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #2

      @AnneRanch call result() the returned type is the same as the QFuture you have set.

      E.g:
      if you set a QFuture of QFuture<QPair<quint64, double>>, then result will return a QPair<quint64, double>


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      A 1 Reply Last reply
      2
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        This was demonstrated in the example provided to another of your threads on this same topic area

        1 Reply Last reply
        3
        • J.HilkJ J.Hilk

          @AnneRanch call result() the returned type is the same as the QFuture you have set.

          E.g:
          if you set a QFuture of QFuture<QPair<quint64, double>>, then result will return a QPair<quint64, double>

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @J-Hilk said in "...back to the future ...":

          @AnneRanch call result() the returned type is the same as the QFuture you have set.

          E.g:
          if you set a QFuture of QFuture<QPair<quint64, double>>, then result will return a QPair<quint64, double>

          OK, that is how return TYPE is specified in QTFuture.
          How is it specified in QTFutureWatcher ?

          I am getting watcher -> return -1 which is obviously an error coming from
          the hci_inquiry . Which is OK and fixable.

          J.HilkJ JKSHJ 2 Replies Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            The watcher is templated on the return type of the future it watches, so you can retrieve the result simply like this:

            int result = watcher->result();
            
            1 Reply Last reply
            4
            • A Anonymous_Banned275

              @J-Hilk said in "...back to the future ...":

              @AnneRanch call result() the returned type is the same as the QFuture you have set.

              E.g:
              if you set a QFuture of QFuture<QPair<quint64, double>>, then result will return a QPair<quint64, double>

              OK, that is how return TYPE is specified in QTFuture.
              How is it specified in QTFutureWatcher ?

              I am getting watcher -> return -1 which is obviously an error coming from
              the hci_inquiry . Which is OK and fixable.

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @AnneRanch said in "...back to the future ...":

              OK, that is how return TYPE is specified in QTFuture.
              How is it specified in QTFutureWatcher ?

              I now realise I should have been more explicit: I highlighted the new part in bold:

              E.g:
              if you set a QFuture of QFuture<QPair<quint64, double>>, then calling QFutureWatcher:: result() will return a QPair<quint64, double> **


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              2
              • A Anonymous_Banned275

                @J-Hilk said in "...back to the future ...":

                @AnneRanch call result() the returned type is the same as the QFuture you have set.

                E.g:
                if you set a QFuture of QFuture<QPair<quint64, double>>, then result will return a QPair<quint64, double>

                OK, that is how return TYPE is specified in QTFuture.
                How is it specified in QTFutureWatcher ?

                I am getting watcher -> return -1 which is obviously an error coming from
                the hci_inquiry . Which is OK and fixable.

                JKSHJ Online
                JKSHJ Online
                JKSH
                Moderators
                wrote on last edited by
                #7

                @AnneRanch said in "...back to the future ...":

                OK, that is how return TYPE is specified in QTFuture.
                How is it specified in QTFutureWatcher ?

                QFutureWatcher gets the type from QFuture. Using C++ templates.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                2

                • Login

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