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. How to correctly Connect from qthreadpool

How to correctly Connect from qthreadpool

Scheduled Pinned Locked Moved Unsolved General and Desktop
qthreadpoolsignalslots
11 Posts 3 Posters 1.4k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Do you mean from your QRunnable subclass ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • P Offline
      P Offline
      PXLFuSSeL
      wrote on last edited by PXLFuSSeL
      #3

      Hy,
      thats what i mean.

      i have implemented a QRunnable to do that work.
      Then i loop through a list were the params in, create an object, connect the signal and slot, and start the work with pool->start().

      But all i get is "Function recv() failed" on console but no entrie in my list.
      Is that correct? Or shall i implement an own kind of threadpool?

      regards,

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Since you have a list of parameters that you iterate, why not use QtConcurrent::map and QFutureWatcher ?

        You'll have the progress indication for free.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • P Offline
          P Offline
          PXLFuSSeL
          wrote on last edited by
          #5

          I know Threadpools from python and thought it works the same way.
          But ok i will give that a shot.

          QImage scaled(const QImage &image)
          {
          return image.scaled(100, 100);
          }

          QList<QImage> images = ...;
          QFuture<QImage> thumbnails = QtConcurrent::mapped(images, scaled);

          like that?

          Thx

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Yes, adding a QFutureWatcher in the mix.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            P 1 Reply Last reply
            2
            • SGaistS SGaist

              Yes, adding a QFutureWatcher in the mix.

              P Offline
              P Offline
              PXLFuSSeL
              wrote on last edited by
              #7

              @SGaist
              hey is there also a way to get the already compute results while running?
              So i want to update the gui, as soon as an results is computed.
              Or isnt it a good idea?

              jsulmJ 1 Reply Last reply
              0
              • P PXLFuSSeL

                @SGaist
                hey is there also a way to get the already compute results while running?
                So i want to update the gui, as soon as an results is computed.
                Or isnt it a good idea?

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @PXLFuSSeL You get the result from QFuture and then update the GUI. Using QFutureWatcher (as @SGaist suggested) you also get notification when a job is finished and then use QFuture to get the result.

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

                P 1 Reply Last reply
                3
                • jsulmJ jsulm

                  @PXLFuSSeL You get the result from QFuture and then update the GUI. Using QFutureWatcher (as @SGaist suggested) you also get notification when a job is finished and then use QFuture to get the result.

                  P Offline
                  P Offline
                  PXLFuSSeL
                  wrote on last edited by
                  #9

                  @jsulm yes that is implemented, but i am interested in getting a result as soon as it is calculated, because am working with really big lists

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    As already hinted twice, QFutureWatcher is your friend.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    P 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      As already hinted twice, QFutureWatcher is your friend.

                      P Offline
                      P Offline
                      PXLFuSSeL
                      wrote on last edited by
                      #11

                      @SGaist yes, thx, my fault was trying to iterate through the future until not be ready.
                      now i got what i want, not as fast as i want, but it works stable.

                      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