Results 1 to 10 of 10

Thread: How to run a console program "silently"?

  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to run a console program "silently"?

    When running a console program through QProcess in a GUI app, you normally expect that nothing pops up and that all output can be smoothly parsed by your app for the confort of the user. unfortunately this is only partly working... When running a console app under windows (9x/ME series at least, I didn't tested under XP) an ugly console windows appears, even if all output is redirected by QProcess. Having used a bunch of apps running console process without seing this console windows appearing I know that what I'm trying to achieve is possible but I don't know how... Source code of other apps, such as Code::Blocks or Dev-Cpp doesn't help much( C::B is written with wxWindows and Dev-Cpp is written in Delphi)...

    Any hints ?
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    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 run a console program "silently"?

    How do you start that external application? Maybe you start it through cmd.exe?

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run a console program "silently"?

    Nop!

    I start them through a QProcess object, and not QProcess::startDetached(), itself owned by a running non-GUI QThread.
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    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 run a console program "silently"?

    I've created a small test:
    Qt Code:
    1. #include <QApplication>
    2. #include <QProcess>
    3. #include <QMessageBox>
    4. #include <QString>
    5.  
    6. int main( int argc, char **argv )
    7. {
    8. QApplication app( argc, argv );
    9.  
    10. QProcess proc;
    11. proc.start("g++ --version");
    12. proc.waitForFinished();
    13.  
    14. QString output( proc.readAllStandardOutput() );
    15.  
    16. QMessageBox::information( 0, "test", output );
    17.  
    18. return 0;
    19. }
    To copy to clipboard, switch view to plain text mode 
    and it doesn't open console window. Maybe this is because you start QProcess in another thread?

  5. #5
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run a console program "silently"?

    This does not work...

    Mmmh, yes it does work but the console windows still appears... It must be specific to Win 9x/ME ...
    Current Qt projects : QCodeEdit, RotiDeCode

  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 run a console program "silently"?

    Quote Originally Posted by fullmetalcoder
    It must be specific to Win 9x/ME ...
    It could be, I've tested above program on windows XP.

  7. #7
    Join Date
    Jul 2006
    Posts
    26
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to run a console program "silently"?

    win9x/ME ??? I thought they died quite a while ago....

  8. #8
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run a console program "silently"?

    do you? You were wrong then... There at least on winME still running on that good old Earth!

    But is that the point anyway?
    Current Qt projects : QCodeEdit, RotiDeCode

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to run a console program "silently"?

    "Good old earth"? Isn't WinME famous of it's memory leaks and stuff. I thought it's maybe the worst Windows ever..
    J-P Nurmi

  10. #10
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to run a console program "silently"?

    It certainly is a great piece of Window$-coding with all the bugs and leaks it implies... AFAI Used it it crashes 1 time over 3 at run-time!!! Impressive, huh? Tha's why I'm using Fedora most of the time, but as it is the only Window$ I've got I use it to test my code so...
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Release my simple program to other users ?
    By probine in forum Qt Programming
    Replies: 9
    Last Post: 10th July 2006, 00:42
  2. Console Program Problem
    By ball in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2006, 10:05
  3. Replies: 1
    Last Post: 17th May 2006, 01:23
  4. why does qt program meet segmentation fault?
    By wquanw in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 15th May 2006, 17:52
  5. Enter key causing program to exit
    By welby in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 17:11

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.