Results 1 to 7 of 7

Thread: Information From Detached Process

  1. #1
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Information From Detached Process

    I'm using a DOS command file to execute a series of actions, including sending text to the DOS screen, etc.

    Example of code:

    Qt Code:
    1. void Clone::selectDriveP()
    2. {
    3. if( driveOnoff)
    4. {
    5. twProcess.startDetached( "TW_install_P.bat");
    6. driveOnoff = false;
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    I think I have to use startDetached in order to see the DOS screen. However, it seems that because I'm using startDetached, I cannot get signals from the detached process such as start(), finished( int , QProcess::ExitStatus), etc.

    Is there something I'm missing?
    Last edited by jpn; 17th February 2008 at 12:43. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Information From Detached Process

    When running batch files, you must use the command prompt:
    Qt Code:
    1. %comspec% /k ""C:\path\to\your\batch\file.bat" x86
    To copy to clipboard, switch view to plain text mode 

    Execute the batch file like that and there will be no need to use start detached.
    Last edited by marcel; 16th February 2008 at 20:51.

  3. #3
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Information From Detached Process

    Not sure how this helps me. Issue isn't how to launch cmd.exe and the batch file.

    How do I get signals back to the parent widget about what the batch file is doing? That's why I wanted to use QProcess.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Information From Detached Process

    You said that you can't see the command line window and that is why you resorted to startDetached.

    In order to see the command window and NOT use startDetached, you must execute the batch file as I have shown you.
    How do I get signals back to the parent widget about what the batch file is doing? That's why I wanted to use QProcess.
    cmd will exit as soon as the batch finishes executing. Therefore start() and finish() will have the correct meaning.

  5. #5
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Information From Detached Process

    I modified the code as follows:

    Qt Code:
    1. void Clone::selectDriveP()
    2. {
    3. if( driveOnoff)
    4. {
    5. arg << "/k" << "tw_install_p.bat";
    6. twProcess.start( "cmd.exe", arg);
    7. driveOnoff = false;
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Note that cmd.exe and tw_install_p.bat are in the parent directory.

    I get a started() signal but no finished() signal. I don't see a dos window and cmd.exe is not seen in Task Manager.

    Clearly I'm doing something stupid here.

  6. #6
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: Information From Detached Process

    Thanks in my thread builder :P

    Try looking at this thread:
    http://www.qtcentre.org/forum/f-qt-p...ess-11463.html

  7. #7
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Information From Detached Process

    I've been assuming that the issue is with starting a command file. However, when I try to run a generic Windows program using the same QProcess and examining the errorString, I get "Unknown Error" even though the Windows program runs normally. Presumably this is why I get a started() signal but no finished() signal.

    Any suggestions about where I should be looking?

Similar Threads

  1. Problem executing process
    By EricF in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2008, 16:04
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

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.