-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.cpp
46 lines (37 loc) · 890 Bytes
/
widget.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
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
game = new gameWidget;
connect(game,&gameWidget::returnSignal,this,&Widget::show);
this->setWindowTitle("五子棋");
background = QPixmap(":/images/ganyu.jpg");
}
void Widget::paintEvent(QPaintEvent *event)
{
// 调用父类的paintEvent函数以确保已经绘制了已存在的内容
QWidget::paintEvent(event);
// 创建QPainter对象
QPainter painter(this);
// 绘制背景图片
painter.drawPixmap(0, 0, width(), height(), background);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_playersButton_clicked()
{
this->hide();
game->show();
game->setGameMode(PLAYER);
}
void Widget::on_AIButton_clicked()
{
this->hide();
game->show();
game->setGameMode(AI);
}