Results 1 to 7 of 7

Thread: why did readyreadstandardoutput signal not work?

  1. #1
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default why did readyreadstandardoutput signal not work?

    hello,everybody.
    I use Qprocess to connect my c program ,but the signal readyreadstandardoutput can not connect to my slot function?
    why?I channge the signal to readyreadstandardError,is works,why?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: why did readyreadstandardoutput signal not work?

    Hi, does your connect() call fail, or do you just get no data with readyReadStandardOutput?
    In the second case, your c program probably writes to stderr, not to stdout.

    Ginsengelf

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: why did readyreadstandardoutput signal not work?

    because QProcess have two seperate channels to read normal output and error
    It also emits readyReadStandardOutput() when new standard output data is available, and when new standard error data is available, readyReadStandardError() is emitted
    if u want a single output use
    setProcessChannelMode(QProcess::MergedChannels);
    "Behind every great fortune lies a crime" - Balzac

  4. The following user says thank you to wagmare for this useful post:

    sunnysun520 (30th July 2009)

  5. #4
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why did readyreadstandardoutput signal not work?

    Quote Originally Posted by Ginsengelf View Post
    Hi, does your connect() call fail, or do you just get no data with readyReadStandardOutput?
    In the second case, your c program probably writes to stderr, not to stdout.

    Ginsengelf
    hi ,I think it failed, because I "cout something" in the slot function,it did not display int the console .

  6. #5
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why did readyreadstandardoutput signal not work?

    Quote Originally Posted by wagmare View Post
    because QProcess have two seperate channels to read normal output and error


    if u want a single output use
    setProcessChannelMode(QProcess::MergedChannels);
    I will try

  7. #6
    Join Date
    May 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why did readyreadstandardoutput signal not work?

    Quote Originally Posted by wagmare View Post
    because QProcess have two seperate channels to read normal output and error


    if u want a single output use
    setProcessChannelMode(QProcess::MergedChannels);
    the following is some of my src code.

    connect(&process,SIGNAL(readyReadStandardOutput()) ,this,SLOT(updaterev_line()));
    。。。。。
    process.setProcessChannelMode(QProcess::SeparateCh annels);
    process.setReadChannel(QProcess::StandardOutput);

    it does not work too!(the signal can not connect the solt func!)

  8. #7
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: why did readyreadstandardoutput signal not work?

    process.setProcessChannelMode(QProcess::SeparateCh annels)
    process.setReadChannel(QProcess::StandardOutput);
    no need to set this one .. it is default ...

    look u will receive readyReadStandardOutput() only when your external application that u are starting using QProcess should have stdOutput() .. if it is giving stdErr() then u cant receive readyReadStandardOutput() ..

    only way to receive stdErr() in readyReadStandardOutput() .. merge the two channels ..
    QProcess merges the output of the running process into the standard output channel (stdout). The standard error channel (stderr) will not receive any data. The standard output and standard error data of the running process are interleaved.
    "Behind every great fortune lies a crime" - Balzac

  9. The following user says thank you to wagmare for this useful post:

    sunnysun520 (31st July 2009)

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. signal of QListWidget doesn't work
    By vito49 in forum Qt Programming
    Replies: 10
    Last Post: 1st October 2008, 05:07
  4. Replies: 3
    Last Post: 15th April 2007, 19:16

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.