experiment
This commit is contained in:
parent
421dee6881
commit
9a638d1312
@ -1,11 +1,40 @@
|
|||||||
#include "mainwindow.h"
|
// main.cpp
|
||||||
#include <QApplication>
|
#include <QtCore>
|
||||||
|
|
||||||
|
class Task : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Task(QObject *parent = 0) : QObject(parent) {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
// Do processing here
|
||||||
|
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void finished();
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "main.moc"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
MainWindow w;
|
|
||||||
w.show();
|
|
||||||
|
|
||||||
return a.exec();
|
// Task parented to the application so that it
|
||||||
|
// will be deleted by the application.
|
||||||
|
Task *task = new Task(&a);
|
||||||
|
|
||||||
|
// This will cause the application to exit when
|
||||||
|
// the task signals finished.
|
||||||
|
QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit()));
|
||||||
|
|
||||||
|
// This will run the task from the application event loop.
|
||||||
|
QTimer::singleShot(0, task, SLOT(run()));
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user