Try doing it the proper way -- connect the readyReadStandardOutput() signal from your process to a slot and read the data there, and don't read a single line, but rather all of them at once.
connect(process, SIGNAL(readyReadStandardOutput ()), this, SLOT(fetchOutput()));
connect(process,
SIGNAL(finished
( int,
QProcess::ExitStatus )),
this,
SLOT(fetchRest
()));
process->start("...");
//...
void thisClass::fetchOutput(){
while(proc->canReadLine()){
cout << proc->readLine().constData() << endl;
}
}
void thisClass::fetchRest(){
cout << proc->readAllStandardOutput().constData();
}
QProcess *process = new QProcess(...);
connect(process, SIGNAL(readyReadStandardOutput ()), this, SLOT(fetchOutput()));
connect(process, SIGNAL(finished ( int, QProcess::ExitStatus )), this, SLOT(fetchRest()));
process->start("...");
//...
void thisClass::fetchOutput(){
QProcess *proc = (QProcess*)sender();
while(proc->canReadLine()){
cout << proc->readLine().constData() << endl;
}
}
void thisClass::fetchRest(){
QProcess *proc = (QProcess*)sender();
cout << proc->readAllStandardOutput().constData();
}
To copy to clipboard, switch view to plain text mode
Bookmarks