Results 1 to 2 of 2

Thread: QProcess state

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QProcess state

    I have a code to detect browser like this:

    Qt Code:
    1. QProcess pProcess;
    2. QString webBrowserCmd;
    3. int return_value =0;
    4. if ( return_value !=2 ) {
    5. webBrowserCmd.clear();
    6. webBrowserCmd.append( "mozilla-firefox " );
    7. webBrowserCmd.append( url );
    8. pProcess.start(webBrowserCmd);
    9. return_value = pProcess.state();
    10. }
    11. // Try with Mozilla
    12. else if ( return_value !=2 ) {
    13. webBrowserCmd.clear();
    14. webBrowserCmd.append( "mozilla " );
    15. webBrowserCmd.append( url );
    16. pProcess.start(webBrowserCmd);
    17. return_value = pProcess.state();
    18. }
    19. // Try with galeon
    20. else if ( return_value !=2 ) {
    21. webBrowserCmd.clear();
    22. webBrowserCmd.append( "galeon " );
    23. webBrowserCmd.append( url );
    24. pProcess.start(webBrowserCmd);
    25. return_value = pProcess.state();
    26. }
    To copy to clipboard, switch view to plain text mode 
    The doc says QProcess::state() return 2 if the process is not running.
    If the browser doesn't exists I try another one, I use pProcess.state() value for this but I'm note sure it will return 1 or 2 in case of failure. Will it always return 2 if the browser doesn't exist? I'm afraid it could return 1 because the process might still be running even if the command failed. Any idea if this is the right way to do it?

    Thanx in advance

    Pat
    Last edited by patcito; 17th January 2006 at 18:53.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess state

    How about searching $PATH to locate appropriate commands?

Similar Threads

  1. Detect First QProcess finished in a group and kill other
    By Davidaino in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 12:53
  2. QProcess exitStatus()
    By user_mail07 in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2008, 20:51
  3. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  4. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  5. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30

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.