Here is an incomplete list of things to consider (look for the comments):
#include <QtCore/QCoreApplication>
#include<QProcess>
#include<stdio.h>
class TIMEOUT{ // << needs to be derived from QObject to contain signals/slots
// << needs the Q_OBJECT macro for the same reason
public:
signals:
void timeout(); // << this should be a slot, not a signal
};
void TIMEOUT::timeout(){
//Help me code there. Thanks
// << You will need code to terminate the process
}
int main(int argc, char *argv[])
{
TIMEOUT timeout;
QObject::connect(&proc,
SIGNAL(timeout.
timeout()),
&a,
SLOT(quit
()));
// << QProcess has no signal called timeout.timeout() proc.execute("C:\\Tesst.exe"); // << this executes the program and waits for it to finish
printf("Hello"); // << Hi!
proc.waitForFinished(1000); // << pointless, the Tesst program has finished before it can get here
return a.exec();
}
#include <QtCore/QCoreApplication>
#include<QProcess>
#include<stdio.h>
class TIMEOUT{ // << needs to be derived from QObject to contain signals/slots
// << needs the Q_OBJECT macro for the same reason
public:
signals:
void timeout(); // << this should be a slot, not a signal
};
void TIMEOUT::timeout(){
//Help me code there. Thanks
// << You will need code to terminate the process
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QProcess proc;
TIMEOUT timeout;
QObject::connect(&proc, SIGNAL(timeout.timeout()),&a, SLOT(quit())); // << QProcess has no signal called timeout.timeout()
proc.execute("C:\\Tesst.exe"); // << this executes the program and waits for it to finish
printf("Hello"); // << Hi!
proc.waitForFinished(1000); // << pointless, the Tesst program has finished before it can get here
return a.exec();
}
To copy to clipboard, switch view to plain text mode
To start and time out and terminate a sub process you will have to read:
The structure of your program will change quite a lot (or it won't compile)
Bookmarks