-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainframe.cpp
More file actions
86 lines (65 loc) · 1.92 KB
/
mainframe.cpp
File metadata and controls
86 lines (65 loc) · 1.92 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "mainframe.h"
#include "stopwatchscene.h"
#include "stopwatchview.h"
#include <QDebug>
#include <QScreen>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QStackedWidget>
MainFrame::MainFrame(QApplication &app)
{
::QFrame();
QRectF sceneRect;
scene = new StopWatchScene(sceneRect);
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
QScreen *primaryScreen = app.primaryScreen();
int scr_w = primaryScreen->geometry().width();
int scr_h = primaryScreen->geometry().height();
scene->setSceneRect(-scr_w/2, -scr_h*2/5, scr_w, scr_h);
#else
scene->setSceneRect(-250, -250, 500, 800);
#endif
view = new StopWatchView(scene);
//view->setFixedSize(QSize(500, 800));
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->centerOn(0,0);
//view->show();
digFrame = new DigFrame();
stack = new QStackedWidget(this);
stack->addWidget(view);
stack->addWidget(digFrame);
stack->setCurrentIndex(0);
//stack->show();
btnGraph = new QPushButton();
btnGraph->setText("Button1");
btnDigit = new QPushButton();
btnDigit->setText("Button2");
QHBoxLayout *layout_top = new QHBoxLayout();
layout_top->setMargin(0);
layout_top->setSpacing(0);
layout_top->addWidget(btnGraph);
layout_top->addWidget(btnDigit);
QVBoxLayout *layout = new QVBoxLayout();
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(stack);
layout->addLayout(layout_top);
setLayout(layout);
connect(btnGraph, SIGNAL(clicked()), this, SLOT(onGraph()));
connect(btnDigit, SIGNAL(clicked()), this, SLOT(onDigit()));
}
MainFrame::~MainFrame()
{
}
void MainFrame::onGraph()
{
//qDebug() << "on Graph";
stack->setCurrentIndex(0);
}
void MainFrame::onDigit()
{
//qDebug() << "on Digit";
stack->setCurrentIndex(1);
}