Results 1 to 7 of 7

Thread: QProcess with a program that call an other ... find stderror

  1. #1
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QProcess with a program that call an other ... find stderror

    Hi evivary,

    I'm using Qprocess to call a program and this is working but this one calls an other program and that stderror of the second program doesn't appear in the QProcess::readAllStandardError()

    Is there a way to do this. To obtain the data in stderror for the other program that is called in the QProcess ?

    Hope u understand the problem.

    Thanks
    ILR

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProcess with a program that call an other ... find stderror

    you need the first process to forward the standard out/err from the second
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess with a program that call an other ... find stderror

    Quote Originally Posted by amleto View Post
    you need the first process to forward the standard out/err from the second
    The first process call the second so i can´t start one and when this finish stsrat the other.

    process->start( "Compiler", args );
    but the compiler use preprocesor.exe and this aparently doesn't execute

    For example:
    When i use the cmd prompt i have this result
    >Compiler arch1
    > output 1: message
    > output 2: message
    ...
    > found errors on arch1

    and when i use QProcess the stderror jus give me the last message

    >found errors on arch 1

    the messages output 1: message are generated by the preprocessor.exe

  4. #4
    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 with a program that call an other ... find stderror

    Each process has its own set of standard output channels. They are not inherited within the process group. Thus, as already said, your intermediate process would need to catch and forward output of the final process.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QProcess with a program that call an other ... find stderror

    Quote Originally Posted by wysota View Post
    Each process has its own set of standard output channels. They are not inherited within the process group. Thus, as already said, your intermediate process would need to catch and forward output of the final process.
    Thnks by the reply and Ok, so the question is how could catch the std output, this is the code that i use:

    I have a class MCompiler : public QProcess

    Qt Code:
    1. MCompiler::MCompiler( )
    2. {
    3. mCompiler = tr( "MCompiler" );
    4.  
    5. QProcessEnvironment pEnv = QProcessEnvironment::systemEnvironment();
    6. pEnv.insert( "TMPDIR", SSPATH );
    7. setProcessEnvironment( pEnv );
    8.  
    9. connect( this, SIGNAL( readyReadStandardOutput( ) ), this, SLOT( compileResult( ) ) );
    10. }
    To copy to clipboard, switch view to plain text mode 

    here is the code when start my compiler

    Qt Code:
    1. void MCompiler::compile( QString fileFullPath )
    2. {
    3. argv << fileFullPath;
    4.  
    5. start( mCompiler, argv );
    6. waitForFinished();
    7. }
    To copy to clipboard, switch view to plain text mode 
    and i have the signal connected to the slot for read the stdOutput

    Qt Code:
    1. void SGWMLSCompiler::compileResult()
    2. {
    3. QByteArray bytes = readAllStandardError();
    4. QStringList lines = QString(bytes).split("\n");
    5.  
    6. foreach (QString line, lines) {
    7. qDebug() << line;
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    And here is where i just get the last std output for Compiler.

  6. #6
    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 with a program that call an other ... find stderror

    Please understand, there is nothing you can do while calling the "compiler". It is the compiler process that has to catch output of its child process. By the way, you are monitoring standard output but reading standard error. Are you sure you are suppposed to do that?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess with a program that call an other ... find stderror

    Thanks wysota. And for your second comment copy-paste error ... but i´m reading the standard output

Similar Threads

  1. How to call WinWord.exe through the Qt program?
    By bangqianchen in forum Qt Programming
    Replies: 11
    Last Post: 7th September 2010, 15:55
  2. How to call another program?
    By shihao in forum Newbie
    Replies: 15
    Last Post: 17th March 2010, 07:42
  3. How to call the dll's C++ class in Qt program?
    By tszzp in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2010, 10:38
  4. Call QProcess without GUI
    By mattia in forum Newbie
    Replies: 8
    Last Post: 5th November 2007, 14:39
  5. QProcess error to call mogrify
    By mattia in forum Newbie
    Replies: 2
    Last Post: 29th October 2007, 12:46

Tags for this Thread

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.