1 Star 8 Fork 2

lazy_forever/基于qt(后端golang+mysql)的五子棋程序

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mainwindow.cpp 2.62 KB
一键复制 编辑 原始数据 按行查看 历史
lazy_forever 提交于 2023-05-01 15:38 . 完善客户端
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include <QPixmap>
#include "mybutton.h"
#include <QTimer>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//设置固定大小
setFixedSize(1000,600);
//设置图标
setWindowIcon(QIcon(":/images/ico.jpg"));
//设置场景标题
setWindowTitle("五子棋游戏");
//设置按钮 分别代表pvp,pve,online模式
mybutton * pvp = new mybutton(":/images/PeoPleTogether.png");
pvp->setParent(this);
pvp->move(this->width()*0.5-pvp->width()*0.5,this->height()*0.7);
mybutton * pve = new mybutton(":/images/PeopleAndComputer.png");
pve->setParent(this);
pve->move(this->width()*0.5-pve->width()*0.5,this->height()*0.4);
mybutton * ponline = new mybutton(":/images/Online.png");
ponline->setParent(this);
ponline->move(this->width()*0.5-ponline->width()*0.5,this->height()*0.1);
//创建游戏对象
playpvp=new pvpScene();
playpve=new pveScene();
playponline=new login();
//监听返回信号
connect(playpvp,&pvpScene::back,[=](){
playpvp->hide();
this->show();
});
connect(playpve,&pveScene::back,[=](){
playpve->hide();
this->show();
});
connect(playponline,&login::back,[=](){
playponline->hide();
this->show();
});
//监听按钮按下操作
connect(pvp,&QPushButton::clicked,[=](){
//做弹起特效
pvp->zoomDown();
pvp->zoomUp();
QTimer::singleShot(400,this,[=](){
//进入下一个场景
this->hide();
playpvp->constructor();
playpvp->show();
});
});
connect(pve,&QPushButton::clicked,[=](){
//做弹起特效
pve->zoomDown();
pve->zoomUp();
QTimer::singleShot(400,this,[=](){
//进入下一个场景
this->hide();
playpve->constructor();
playpve->show();
});
});
connect(ponline,&QPushButton::clicked,[=](){
//做弹起特效
ponline->zoomDown();
ponline->zoomUp();
QTimer::singleShot(400,this,[=](){
//进入下一个场景
this->hide();
playponline->loginupdate();
playponline->show();
});
});
}
void MainWindow::paintEvent(QPaintEvent *){
QPainter painter(this);
//画背景图
QPixmap pix;
pix.load(":/images/background.png");
painter.drawPixmap(0,0,1000,600,pix);
}
MainWindow::~MainWindow()
{
delete ui;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/lazy_forever/five2line.git
git@gitee.com:lazy_forever/five2line.git
lazy_forever
five2line
基于qt(后端golang+mysql)的五子棋程序
master

搜索帮助