1 Attachment(s)
Why this code doesn't work?
Qt version: 4.4.3.
OS: Ubuntu Linux Desktop Edition 8.10 x86.
The following code does not insert the "ls -hal" output to the QTextEdit object. The QTextEdit object appears empty. Why?
A screenshot is attached.
Code:
#include <QApplication>
#include <QDialog>
#include <QProcess>
#include "ui_qsysv-rc-conf.h"
int main(int argc, char *argv[])
{
Ui::Dialog ui;
ui.setupUi(dialog);
dialog->show();
sysvProcess->start("ls -hal");
const QByteArray &input
= sysvProcess
->readAllStandardOutput
();
ui.
textEdit->setText
(QString(input
));
app.exec();
return 0;
}
Re: Why this code doesn't work?
Try use QProcess::waitForFinished maybe your QProcess sysvProcess has not alreasy written anything to stdoutput when you call readAllStandardOutput().
Re: Why this code doesn't work?
try something like this:
Code:
arguments << "-c" << "ls -hal";
process->start(prog , arguments);
process->waitForFinished();
qDebug() << tmp;
ui.textEdit->setText(tmp);