-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmywindow.cpp
More file actions
85 lines (68 loc) · 1.87 KB
/
mywindow.cpp
File metadata and controls
85 lines (68 loc) · 1.87 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 "mywindow.h"
#include "mybutton.h"
#include "window1.h"
#include "window2.h"
#include <QPixmap>
#include <QPainter>
#include <QTimer>
MyWindow::MyWindow(QWidget *parent) : QMainWindow(parent)
{
this->setFixedSize(900,800);
//返回按钮
MyButton * rbtn=new MyButton(":/returnbtn.png");
rbtn->setParent(this);
rbtn->move(50,50);
connect(rbtn,&QPushButton::clicked,this,[=](){
rbtn->down();
rbtn->up();
});
connect(rbtn,&MyButton::clicked,this,[=](){
QTimer::singleShot(200,this,[=](){
emit chooseBack(); //发送返回信号
});
});
Window1 *scene1 = new Window1;
Window2 *scene2 = new Window2;
connect(scene1,&Window1::chooseBack,this,[=](){
scene1->hide();
this->show();
});
connect(scene2,&Window2::chooseBack,this,[=](){
scene2->hide();
this->show();
});
//场景1
MyButton * cbtn1=new MyButton(":/choose1.png");
cbtn1->setParent(this);
cbtn1->move(150,300);
connect(cbtn1,&QPushButton::clicked,this,[=](){
cbtn1->down();
cbtn1->up();
QTimer::singleShot(200,this,[=](){
this->hide();
scene1->show();
});
});
//场景2
MyButton * cbtn2=new MyButton(":/choose2.png");
cbtn2->setParent(this);
cbtn2->move(575,300);
connect(cbtn2,&QPushButton::clicked,this,[=](){
cbtn2->down();
cbtn2->up();
QTimer::singleShot(200,this,[=](){
this->hide();
scene2->show();
});
});
//设置标题
title->setText("Choose a scene!");
title->setGeometry(360, 15, 240, 100);
title->setFont(QFont("Consolas", 20));
title->show();
}
void MyWindow::paintEvent(QPaintEvent *){
QPainter painter(this);
QPixmap pixmap(":/choose.jpg");
painter.drawPixmap(0,0,this->width(),this->height(),pixmap);
}