-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (40 loc) · 997 Bytes
/
Copy pathmain.cpp
File metadata and controls
52 lines (40 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <QGuiApplication>
#include <QQuickView>
#include <QObject>
#include <QDebug>
class VDestroyer : public QObject
{
Q_OBJECT
public:
explicit VDestroyer(QQuickView *view, QObject *parent = 0) :
QObject(parent), m_view(view)
{
// destroy m_view in 5 secs
timerId = startTimer(5 * 1000);
}
protected:
void timerEvent(QTimerEvent * event)
{
if (event->timerId() == timerId) {
m_view->deleteLater();
}
}
private :
QQuickView *m_view;
int timerId;
};
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
qDebug() << "Hello, World";
app.setQuitOnLastWindowClosed(false);
QQuickView *view = new QQuickView;
view->setSource(QUrl(QStringLiteral("qrc:/main.qml")));
view->show();
VDestroyer *vDestroyer = new VDestroyer(view);
int rc = app.exec();
qDebug() << "exiting from application!!";
delete vDestroyer;
return rc;
}
#include "main.moc"