Small problem with QProcess output



  • --hi to all i got small problem i just want to create tcl shell using QProcess...but "puts" command is working..but when i enter "set a 10" it is not giving any output...but i entr the same command directly in the console it is printing 10...can some one plese tell me how to capture those type of outputs...
    @
    costructor
    {
    proc = new QProcess();
    proc->start( "tclsh" );

     textEdit->addAction( actionClear_All );
    // connects
    connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( captureProcessOutput() ));
    connect( proc, SIGNAL( readyReadStandardError() ), this, SLOT( captureProcessError() ));
    
    connect( lineEdit, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() ) );
    connect( proc, SIGNAL( finished( int, QProcess::ExitStatus) ), this, SLOT( processFinished(int,QProcess::ExitStatus ) ));
    

    }

    void MainWindow::lineEditReturnPressed()
    {
    proc->write( qPrintable( lineEdit->text()+'\n' ) );
    }

    void MainWindow::captureProcessOutput()
    {
    textEdit->append( proc->readAllStandardOutput() );
    }
    void MainWindow::captureProcessError()
    {
    textEdit->append( proc->readAllStandardError() );
    }
    void MainWindow::processFinished( int exitCode, QProcess::ExitStatus )
    { Q_UNUSED( exitCode );
    qApp->quit();
    }@



  • You're most probably hit by stdout buffering. You will have to make sure that tclsh flushes the output buffer. Default is usually 4096 bytes (4k). If you cannot trick tclsh or your tcl script into flushing the buffer, there’s no other option than waiting until the OS flushes it.



  • But only few commands facing this problem..after executing the set command if i execute increment command it is working..only the set command output not displying..



  • Sorry, I have absolutely no knowledge about tclsh and how it behaves. I can only give general advice here, and usually problems caused by "missing" stdout from a QProcess is caused by some buffering on the started process' side...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.