-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
126 lines (103 loc) · 3.97 KB
/
mainwindow.cpp
File metadata and controls
126 lines (103 loc) · 3.97 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "mainwindow.h"
void MainWindow::paintEvent(QPaintEvent *)
{
//创建画家,指定绘图设备
QPainter painter(this);
//创建QPixmap对象
QPixmap pix;
//加载图片
pix.load(":/img/bei_jing.jpg");
//绘制背景图
painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
//初始化界面宽高属性
void MainWindow::init_width_height()
{
//获取当前屏幕分辨率
QScreen *screen=QGuiApplication::primaryScreen ();
QRect mm=screen->availableGeometry() ;
#ifdef ANDROID
this->my_app_data->width_ture = mm.width();
this->my_app_data->height_ture = mm.height();
this->my_app_data->width = (float)my_app_data->width_ture / 100.00f;
this->my_app_data->height = (float)my_app_data->height_ture / 100.00f;
this->my_app_data->main_widget->setWhatsThis("zxc");
this->my_app_data->main_widget->resize(my_app_data->width_ture,my_app_data->height_ture);
return;
#endif
this->my_app_data->width_ture = mm.height() / 2;
this->my_app_data->width = (float)my_app_data->width_ture / 100.00f;
this->my_app_data->height_ture = mm.width()/2 - (int)(mm.width()/2*0.2);
this->my_app_data->height = (float)my_app_data->height_ture / 100.00f;
this->my_app_data->main_widget->setWhatsThis("zxc");
this->my_app_data->main_widget->resize(my_app_data->width_ture,my_app_data->height_ture);
}
//初始化栈容器
void MainWindow::init_stacked()
{
//安卓端,信息栏底色填充
this->andorid_temp = new QStackedWidget(this);
this->andorid_temp->resize(my_app_data->width_ture,my_app_data->height*3.1);
this->andorid_temp->move(0,0);
this->andorid_temp->addWidget(new QTabWidget(this));
//创建栈容器
this->stacked = new QStackedWidget(this);
this->stacked->move(0,my_app_data->height*3);
this->stacked->resize(my_app_data->width_ture,my_app_data->height*89);
//创建第一个页面
zhouyi_tab_widget* my_stack_widget_one = new zhouyi_tab_widget(this);
this->stacked->addWidget((QTabWidget*)my_stack_widget_one);
//创建第二个页面
laozi_widget * my_laozi = new laozi_widget(this);
this->stacked->addWidget((QWidget*)my_laozi);
}
//初始化栈容器切换按钮
void MainWindow::init_push_button()
{
this->zhouyi = new QPushButton(this);
this->zhouyi->setText("周易速记");
this->zhouyi->setFont(QFont ( "Microsoft YaHei", 15, 87 ));
this->zhouyi->resize(this->my_app_data->width*(100/PB_NUM),this->my_app_data->height*8);
this->zhouyi->move(this->my_app_data->width*(100/PB_NUM)*0,this->my_app_data->height*92);
connect(this->zhouyi,&QPushButton::clicked,this,[=](){
this->stacked->setCurrentIndex(0);
});
this->laozi = new QPushButton(this);
this->laozi->setText("老子体会");
this->laozi->setFont(QFont ( "Microsoft YaHei", 15, 87 ));
this->laozi->resize(this->my_app_data->width*(100/PB_NUM),this->my_app_data->height*8);
this->laozi->move(this->my_app_data->width*(100/PB_NUM)*1,this->my_app_data->height*92);
connect(this->laozi,&QPushButton::clicked,this,[=](){
emit ((laozi_widget*)this->stacked->widget(1))->sig_thr_text_edited();
this->stacked->setCurrentIndex(1);
});
}
//初始化透明度
void MainWindow::init_clarity()
{
int a =5;
QGraphicsOpacityEffect *effect[a];
for (int i =0;i<a;i++)
{
effect[i]= new QGraphicsOpacityEffect(this);
effect[i]->setOpacity(0.8); // 设置透明度
}
this->laozi->setGraphicsEffect(effect[0]);
this->zhouyi->setGraphicsEffect(effect[1]);
this->stacked->setGraphicsEffect(effect[2]);
this->andorid_temp->setGraphicsEffect(effect[3]);
}
MainWindow::MainWindow (QWidget *parent)
: QMainWindow(parent)
{
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
my_app_data = app_data::get_app_data();
my_app_data->main_widget =this;
this->init_width_height();
this->init_stacked();
this->init_push_button();
this->init_clarity();
}
MainWindow::~MainWindow()
{
}