I have a console application that looks for a device on the network and gets data from it. It will either get the data within a few seconds or it get stuck in trying to receive data.
So I wanted to set up a Qtimer that would preform a quit after 10 seconds. Here is my code but it does not seem to work.
int main(int argc, char *argv[])
{
QTimer::singleShot(10000,
&a,
SLOT(quit
()));
// either will return within 3 seconds or get stuck trying to do a read.
LLDP::Execute();
return a.exec();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTimer::singleShot(10000, &a, SLOT(quit()));
// either will return within 3 seconds or get stuck trying to do a read.
LLDP::Execute();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
It is pretty much exactly what is in the singleShot documentation. My code is where the "..." are.
#include <QApplication>
#include <QTimer>
int main(int argc, char *argv[])
{
QTimer::singleShot(600000,
&app,
SLOT(quit
()));
...
return app.exec();
}
#include <QApplication>
#include <QTimer>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTimer::singleShot(600000, &app, SLOT(quit()));
...
return app.exec();
}
To copy to clipboard, switch view to plain text mode
What am I doing wrong and what is the correct way?
Bookmarks