Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Small problem with QProcess output
Forum Updated to NodeBB v4.3 + New Features

Small problem with QProcess output

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mahesh
    wrote on last edited by
    #1

    --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();
    }@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mahesh
        wrote on last edited by
        #3

        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..

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          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...

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved