-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
48 lines (42 loc) · 1.04 KB
/
mainwindow.cpp
File metadata and controls
48 lines (42 loc) · 1.04 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPixmap>
#include <QPainter>
#include <QPaintEvent>
#include <QPushButton>
#include <QDebug>
#include <QTimer>
#include"mybutton.h"
#include"mywindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
this->setFixedSize(900,800);
ui->setupUi(this);
MyButton *btn = new MyButton(":/button1.png");
btn->setParent(this);
btn->move(700,500);//按钮位置
MyWindow *scene = new MyWindow;
connect(btn,&QPushButton::clicked,this,[=](){
btn->down();
btn->up();
QTimer::singleShot(200,this,[=](){
this->hide();
scene->show();
});
});
connect(scene,&MyWindow::chooseBack,this,[=](){
scene->hide();
this->show();
});
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::paintEvent(QPaintEvent *){
QPainter painter(this);
QPixmap pixmap(":/mainscreen.jpeg");
painter.drawPixmap(0,0,this->width(),this->height(),pixmap);
}