irgendwie stehe ich etwas auf dem Schlauch.
Szenario: Ich rufe ein externes Programm auf und will es, wenn es beendet wird, direkt neustarten. Mein kleiner test dazu:
process.h
Code: Alles auswählen
#ifndef PROCESS_H
#define PROCESS_H
#include <QObject>
#include <QProcess>
class Process : public QObject
{
Q_OBJECT
public:
explicit Process(QObject *parent = 0);
QProcess *myProcess;
signals:
public slots:
void restartslot();
private:
void init();
};
#endif // PROCESS_H
Code: Alles auswählen
#include "process.h"
#include <stdio.h>
Process::Process(QObject *parent) :
QObject(parent)
{
myProcess = new QProcess(this);
if ( connect(myProcess,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(restartslot()))) {
printf("Connect erfolgreich\n");
}
init();
}
void Process::init() {
myProcess->start("calc.exe", QStringList());
//Funktioniert nur mit waitForFinished(), sonst wird das Signal nicht ausgelöst.
//myProcess->waitForFinished();
}
void Process::restartslot()
{
init();
}
Code: Alles auswählen
Process *test = new Process(0);
Ich hab nun schon einige Beiträge dazu gelesen und sehe da keinen Unterschied. Zur not steige ich auf die Winapi um, aber ich wollte eigentlich ganz gerne Plattformunabhängig bleiben.
2. Noch eine kleine Verständnisfrage :
Kann ich über die Signale
Code: Alles auswählen
void error ( QProcess::ProcessError error )
void readyReadStandardError ()
void readyReadStandardOutput ()
Danke im Voraus und schönen 4. Advent .