-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (36 loc) · 1.39 KB
/
main.cpp
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
#include <QApplication>
#include <QGLWidget>
#include <QDeclarativeView>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDeclarativeContext>
#include <QDeclarativeItem>
#include "src/random.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
qmlRegisterType<Random>("com.planrich.aircontrol",1,0,"Random");
QDeclarativeEngine engine;
QDeclarativeComponent mainComponent(&engine,QUrl("qrc:/Main.qml"));
QObject * obj = mainComponent.create();
QDeclarativeItem * item = qobject_cast<QDeclarativeItem*>(obj);
QGraphicsScene scene;
scene.setStickyFocus(true);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
QGraphicsView view(&scene);
view.setOptimizationFlags(QGraphicsView::DontSavePainterState);
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
view.viewport()->setFocusPolicy(Qt::NoFocus);
view.setFocusPolicy(Qt::StrongFocus);
view.setWindowTitle(QObject::tr("Aircontrol"));
view.setWindowFlags(Qt::FramelessWindowHint);
view.setViewport(new QGLWidget);
scene.addItem(item);
view.setGeometry(0,0,item->width(),item->height());
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
app.connect(&engine, SIGNAL(quit()),
&view, SLOT(close()));
view.show();
return app.exec();
}