ich habe eine Frage zu der Klasse QProcess, da die Methode write() bei mir
nur einmal funktioniert bzw. ein Ergebnis produziert. Hier der Code:
Code: Alles auswählen
// *** Hier ist der Konstruktor
TQConsole::TQConsole(void)
{
QString strIn,
strOut,
strErr,
strTitle,
strText;
T_ITE ITE;
// *** importing widgets
ui.setupUi(this);
// *** connecting slots
connect(ui.btnClose , SIGNAL(clicked()) , this, SLOT(btnCloseClick(void)));
this->pProcess = new QProcess();
connect(this->pProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput(void)));
this->pProcess->setWorkingDirectory("/media/flash/deva/der500");
this->pProcess->start("/bin/bash");
if (this->pProcess->waitForStarted() == false)
{
strTitle = ITE.SFehler;
strText = "Der Prozess konnte nicht gestartet werden.";
ShowMessage(strTitle,strText,QMessageBox::Ok,QMessageBox::Critical);
}
else
{
ui.textEdit->clear();
this->pProcess->setReadChannel(QProcess::StandardOutput);
this->pProcess->write("whoami\n"); // geht, also mit Reaktion im slot
this->pProcess->write("whoami\n"); // geht nicht, also ohne Reaktion im slot
}
ui.textEdit->setFocusProxy(this);
this->Command = "";
}
// *** Nun kommt der slot zum lesen
void TQConsole::onReadyReadStandardOutput(void)
{
QString strLine;
strLine = this->pProcess->readAll();
ui.textEdit->append(strLine);
qDebug() << "strLine=" << strLine;
}
Danke und Gruß
Jasper