PDA

View Full Version : QProcess::readAllStandardOutput and QTextEdit



naptizaN
12th December 2012, 16:53
Hello everyone. Made a small gui for free console av scanner for personal use. Used QProcess::readAllStandardOutput to read command lines. But it's too much information in output in QString output; (like information about scanner, it's commands etc). I just want to see what it's currently scanning and what has found. Below is is some code from my program. QProcess ps, QString output, QString param (gave some parameters with gui). How can i get rid of not usefull information? Set some sort of filter or delete/replace from QString?


MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass) {
ui->setupUi(this);
......
connect(&ps, SIGNAL(readyRead()), this, SLOT(on_cmdExec_data_available()));
}

void MainWindow::on_scanButton_clicked() {

output = "";
ps.start(param);
QTextCursor c = ui->textEdit_output->textCursor();
c.movePosition(QTextCursor::End);
ui->textEdit_output->setTextCursor(c);
ui->textEdit_output->ensureCursorVisible();
}

void MainWindow::on_cmdExec_data_available() {
output += ps.readAllStandardOutput();
ui->textEdit_output->append(output);
}
}

void MainWindow::on_stopButton_clicked() {
ps.kill();
}

naptizaN
13th December 2012, 08:50
The output from QProcess::readAllStandardOutput is QByteArray. How to set filter on what i am addind from QByteArray to QString?