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. Qtconcurrent finish signal ...
Forum Updated to NodeBB v4.3 + New Features

Qtconcurrent finish signal ...

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 5.1k Views 1 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by
    #1

    I would like to get the finisched signal from my qtconcurrent <void> to use it in a signal slot mechanism ... i need to use qtfuturewatcher and qtfuture? .... my void read some file on lan and charge the file name on Qlist .... when the operation is finish I need to have finish signal because I have a lot of these type of operation (10) so i can update my progress bar every action was finisch ..... or reuse the same void for reading file to other folder ....

    regards
    giorgio

    bkt

    jsulmJ 1 Reply Last reply
    0
    • gfxxG gfxx

      I would like to get the finisched signal from my qtconcurrent <void> to use it in a signal slot mechanism ... i need to use qtfuturewatcher and qtfuture? .... my void read some file on lan and charge the file name on Qlist .... when the operation is finish I need to have finish signal because I have a lot of these type of operation (10) so i can update my progress bar every action was finisch ..... or reuse the same void for reading file to other folder ....

      regards
      giorgio

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @gfxx You should really use correct wording: "qtconcurrent <void>" - do you mean QtConcurrent::run? "or reuse the same void" - use same void, what does it mean?
      So, do you use QtConcurrent::run? If so, then yes you need to use QFuture and QFutureWatcher.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      gfxxG 1 Reply Last reply
      0
      • jsulmJ jsulm

        @gfxx You should really use correct wording: "qtconcurrent <void>" - do you mean QtConcurrent::run? "or reuse the same void" - use same void, what does it mean?
        So, do you use QtConcurrent::run? If so, then yes you need to use QFuture and QFutureWatcher.

        gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on last edited by
        #3

        @jsulm Thanks ... real sorry for bad written worlds .... I promise that in the coming months I will start an English course .... because I'm tired of seeing my words are not well written.

        Anyway thanks a lot.
        giorgio

        bkt

        jsulmJ 1 Reply Last reply
        0
        • gfxxG gfxx

          @jsulm Thanks ... real sorry for bad written worlds .... I promise that in the coming months I will start an English course .... because I'm tired of seeing my words are not well written.

          Anyway thanks a lot.
          giorgio

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @gfxx Its not about your English, it is more about the correct terms. For example: it is QtConcurrent::run, not QtConcurrent<void>. The problem with wrong terms is that it can be hard to understand what is actually meant.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          gfxxG 1 Reply Last reply
          0
          • jsulmJ jsulm

            @gfxx Its not about your English, it is more about the correct terms. For example: it is QtConcurrent::run, not QtConcurrent<void>. The problem with wrong terms is that it can be hard to understand what is actually meant.

            gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by
            #5

            @jsulm .... I think I use these structure of code:

            #include <QCoreApplication>
            #include <qtconcurrentrun.h>
            #include <QThread>
            
            #ifndef QT_NO_CONCURRENT
            
            void myRunFunction(QString name)
            {
                for(int i = 0; i <= 5; i++)
                {
                    qDebug() << name << " " << i <<
                                "from" << QThread::currentThread();
                }
            }
            
            int main(int argc, char *argv[])
            {
                QCoreApplication a(argc, argv);
            
                QFuture<void> t1 = QtConcurrent::run(myRunFunction, QString("A"));
                QFuture<void> t2 = QtConcurrent::run(myRunFunction, QString("B"));
                QFuture<void> t3 = QtConcurrent::run(myRunFunction, QString("C"));
            
                t1.waitForFinished();
                t2.waitForFinished();
                t3.waitForFinished();
            
                return a.exec();
            }
            
            #else
            
            #include <QLabel>
            
            int main(int argc, char *argv[])
            {
                QApplication app(argc, argv);
                QString text("Qt Concurrent is not yet supported on this platform");
            
                QLabel *label = new QLabel(text);
                label->setWordWrap(true);
            
                label->show();
                qDebug() << text;
            
                app.exec();
            }
            #endif
            

            in these case QFuture<void> t1 = QtConcurrent::run(myRunFunction, QString("A")); I think to use these row of code. So I better re-write my question:

            For bring "isfinished SIGNAL" in these case I must use QFutureWatcher?

            You are in right ... my terminology is wrong .... I had to say QFuture <void> and not Qconcurrent <void> .... or say to use a Void with Qcouncurrent and get an isfinished signal ...

            So my terminology is bad as my english :)) .... So I do not think it's such a bad thing to spend my money on an English course.

            Have a Happy day ... and Thanks a lot.

            Giorgio

            bkt

            J.HilkJ 1 Reply Last reply
            0
            • gfxxG gfxx

              @jsulm .... I think I use these structure of code:

              #include <QCoreApplication>
              #include <qtconcurrentrun.h>
              #include <QThread>
              
              #ifndef QT_NO_CONCURRENT
              
              void myRunFunction(QString name)
              {
                  for(int i = 0; i <= 5; i++)
                  {
                      qDebug() << name << " " << i <<
                                  "from" << QThread::currentThread();
                  }
              }
              
              int main(int argc, char *argv[])
              {
                  QCoreApplication a(argc, argv);
              
                  QFuture<void> t1 = QtConcurrent::run(myRunFunction, QString("A"));
                  QFuture<void> t2 = QtConcurrent::run(myRunFunction, QString("B"));
                  QFuture<void> t3 = QtConcurrent::run(myRunFunction, QString("C"));
              
                  t1.waitForFinished();
                  t2.waitForFinished();
                  t3.waitForFinished();
              
                  return a.exec();
              }
              
              #else
              
              #include <QLabel>
              
              int main(int argc, char *argv[])
              {
                  QApplication app(argc, argv);
                  QString text("Qt Concurrent is not yet supported on this platform");
              
                  QLabel *label = new QLabel(text);
                  label->setWordWrap(true);
              
                  label->show();
                  qDebug() << text;
              
                  app.exec();
              }
              #endif
              

              in these case QFuture<void> t1 = QtConcurrent::run(myRunFunction, QString("A")); I think to use these row of code. So I better re-write my question:

              For bring "isfinished SIGNAL" in these case I must use QFutureWatcher?

              You are in right ... my terminology is wrong .... I had to say QFuture <void> and not Qconcurrent <void> .... or say to use a Void with Qcouncurrent and get an isfinished signal ...

              So my terminology is bad as my english :)) .... So I do not think it's such a bad thing to spend my money on an English course.

              Have a Happy day ... and Thanks a lot.

              Giorgio

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

              @gfxx If I'm not totally wrong, than you can simply emit a Signal at the end of your run funtion!

              void myRunFunction(QString name)
              {
                  for(int i = 0; i <= 5; i++)
                  {
                      qDebug() << name << " " << i <<
                                  "from" << QThread::currentThread();
                  }
                  emit runIsDone();
              }
              

              Just connect that Signal to a Slot and go from there. To be sure give the Connect a Qt::QueuedConnection as 5th parameter.


              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.

              gfxxG 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @gfxx If I'm not totally wrong, than you can simply emit a Signal at the end of your run funtion!

                void myRunFunction(QString name)
                {
                    for(int i = 0; i <= 5; i++)
                    {
                        qDebug() << name << " " << i <<
                                    "from" << QThread::currentThread();
                    }
                    emit runIsDone();
                }
                

                Just connect that Signal to a Slot and go from there. To be sure give the Connect a Qt::QueuedConnection as 5th parameter.

                gfxxG Offline
                gfxxG Offline
                gfxx
                wrote on last edited by gfxx
                #7

                @J.Hilk said in Qtconcurrent finish signal ...:

                f I'm not totally wrong, than you can simply emit a Signal at the end of your run funtion!

                you are in right ... these is my ideas too .... an in the afternoon I try .... but I would know if there are some other SIGNAL type already ready, without make a new one .....

                regards
                giorgio

                bkt

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Asperamanca
                  wrote on last edited by Asperamanca
                  #8

                  Structure is more or less like this:

                     QFuture<MyClass> future = QtConcurrent::run(function,..);
                     QFutureWatcher<MyClass>* pWatcher = new QFutureWatcher(parent);
                     pWatcher->setFuture(future);
                     // Now I can use signals emitted by pWatcher
                  
                  gfxxG 1 Reply Last reply
                  2
                  • A Asperamanca

                    Structure is more or less like this:

                       QFuture<MyClass> future = QtConcurrent::run(function,..);
                       QFutureWatcher<MyClass>* pWatcher = new QFutureWatcher(parent);
                       pWatcher->setFuture(future);
                       // Now I can use signals emitted by pWatcher
                    
                    gfxxG Offline
                    gfxxG Offline
                    gfxx
                    wrote on last edited by
                    #9

                    @Asperamanca thanks.

                    bkt

                    1 Reply Last reply
                    0

                    • Login

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