Results 1 to 10 of 10

Thread: How to detect a QProcess is started

  1. #1
    Join Date
    Sep 2007
    Posts
    13
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to detect a QProcess is started

    I start the process A before my main application starts using startDetached of QProcess.
    However I having problem of the main application lose focus to process A.
    I have try to set back focus to main application, however the process A is actually show up slower than the main application. So, my code of set focus will finish run even before process A runs finished and get the focus.

    How to actually detect when process A is started? When process A start up it only shows as system tray icon.
    Last edited by cooler123; 20th June 2008 at 10:54.

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to detect a QProcess is finished running

    Hi,

    Take a look at QProcess::finished signal
    Òscar Llarch i Galán

  3. #3
    Join Date
    Sep 2007
    Posts
    13
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to detect a QProcess is finished running

    Oops, my mistake.
    I actually need to know when the process A actually started and not finished running.

  4. #4
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to detect a QProcess is started


  5. #5
    Join Date
    Sep 2007
    Posts
    13
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to detect a QProcess is started

    I use startDetached to start the process that will not affect my main application.
    I have try all the signal, started, finished, stateChanged... all also not working. No signal is returned.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to detect a QProcess is started

    Quote Originally Posted by cooler123 View Post
    I use startDetached to start the process that will not affect my main application.
    I have try all the signal, started, finished, stateChanged... all also not working. No signal is returned.
    QProcess::startDetached() is a static method, so there is no QProcess object you can connect to to receive the signal from. Use QProcess::start() instead.

  7. #7
    Join Date
    Sep 2007
    Posts
    13
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to detect a QProcess is started

    After i use start() to start the process, can I detached it after that?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to detect a QProcess is started

    Quote Originally Posted by cooler123 View Post
    After i use start() to start the process, can I detached it after that?
    No, you can't. QProcess will kill its child processes. Maybe you could someway determine the state of child process if you had its PID?

  9. #9
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to detect a QProcess is started

    Why you need to detach the child process? If you don't call the waitForFinished() function the child process will not block your application and you will be able to monitor it well.

  10. #10
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to detect a QProcess is started

    The QProcess:startDetached function returns TRUE on success and set pid argument
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 5
    Last Post: 9th June 2008, 11:21
  2. Connecting with QProcess to an already running process
    By high_flyer in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2007, 10:31
  3. Detect platform where my QT4 program is running on
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 12:01
  4. QProcess / system call not working under linux. Why?
    By johnny_sparx in forum Qt Programming
    Replies: 12
    Last Post: 11th March 2006, 00:32

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.