Results 1 to 5 of 5

Thread: Multiple QProcesses running in parallel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Multiple QProcesses running in parallel

    Hi All,

    I've been scratching my head on this one this afternoon, and wonder whether anyone has done this before.

    I have an external process which i want to run multiple time in a parallel to get some information for my application. When each process returns, I want to store that information.

    I can do this by having a class which stores the information, and then making each of these object have a qprocess, so when the process returns, i can store the details in the correct place.

    However, say i need to do this n number of times. How will i know when all of the qprocesses have finished?

    David

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QProcesses running in parallel

    How will i know when all of the qprocesses have finished?
    have you read the QProcess docs?
    There are many ways you can do this:
    using the signal finished(), polling for the state(), or maybe waitForFinished() just at first glance.
    Which one is best for your case, is hard for me to tell with out knowing more about your code.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QProcesses running in parallel

    Yeah. I know i can use the finished() signal.

    I think what i will do is connect each finished signal to a function SLOTGotInfo(), in it's own class, as well as a SLOTDecrementProcessCount() signal in the main code, where i start all the processes.

    Since I know how many processes i will be starting in the first place, when my process count gets to 0, i know all the processes have finished. Just need to put a lock around access to ProcessCount.

    As a side question. There are many times like these when i want to connect a one slot to different signals, and when the signal causes the slot to be processes, find out which objects signal caused the slot to be called. Do you know if this is possible?

    David

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QProcesses running in parallel

    There are many times like these when i want to connect a one slot to different signals, and when the signal causes the slot to be processes, find out which objects signal caused the slot to be called. Do you know if this is possible?
    See QObject::sender();
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QProcesses running in parallel

    Just taken a look at the docs for QObject::sender(). It's the answer to all my prayers!!

    I can feel some refactoring of some of my code coming on, since I have previously passed pointers to objects around myself in slots, to do this!

Similar Threads

  1. QThread - parallel
    By sgrant327 in forum Qt Programming
    Replies: 13
    Last Post: 13th April 2010, 15:48
  2. Replies: 1
    Last Post: 6th February 2010, 10:54
  3. Parallel Interface
    By r00tz in forum Qt Programming
    Replies: 31
    Last Post: 19th November 2007, 13:50
  4. Parallel and serial I/O
    By Roberto in forum Qt Programming
    Replies: 3
    Last Post: 10th October 2007, 12:53
  5. How should I thread these QProcesses?
    By last2kn0 in forum Qt Programming
    Replies: 8
    Last Post: 9th October 2007, 05:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.