setAutoFillBackground(true);//覆盖this->resize(480,270);this->setWindowIcon(QIcon("img/icon.jpg"));this->setWindowTitle("贪吃蛇");QPalettepalette;palette.setBrush(QPalette::Background,QBrush((QPixmap)"img/bjt.png"));this->setPalette(palette);//按扭区leftbtn=newQPushButton(this);leftbtn->setIcon((QIcon)"img/zuo.png");leftbtn->setIconSize(QSize(40,40));leftbtn->setGeometry(QRect(340,180,40,40));leftbtn->setFlat(true);rightbtn=newQPushButton(this);rightbtn->setIcon((QIcon)"img/you.png");rightbtn->setIconSize(QSize(40,40));rightbtn->setGeometry(QRect(430,180,40,40));rightbtn->setFlat(true-IMDN开发者社群-imdn.cn"> setAutoFillBackground(true);//覆盖this->resize(480,270);this->setWindowIcon(QIcon("img/icon.jpg"));this->setWindowTitle("贪吃蛇");QPalettepalette;palette.setBrush(QPalette::Background,QBrush((QPixmap)"img/bjt.png"));this->setPalette(palette);//按扭区leftbtn=newQPushButton(this);leftbtn->setIcon((QIcon)"img/zuo.png");leftbtn->setIconSize(QSize(40,40));leftbtn->setGeometry(QRect(340,180,40,40));leftbtn->setFlat(true);rightbtn=newQPushButton(this);rightbtn->setIcon((QIcon)"img/you.png");rightbtn->setIconSize(QSize(40,40));rightbtn->setGeometry(QRect(430,180,40,40));rightbtn->setFlat(true - IMDN开发者社群-imdn.cn">
登录
首页 » Windows开发 » QT编写的C++贪吃蛇小游戏

QT编写的C++贪吃蛇小游戏

于 2022-03-21 发布 文件大小:730.86 kB
0 87
下载积分: 2 下载次数: 1

代码说明:

游戏通过按键控制 部分代码: #include "gamewidget.h" #define ROW 13 #define COL 16 #define UP 0 #define DOWN 1 #define LEFT 2 #define RIGHT 3 GameWidget::GameWidget(QWidget *parent) :QWidget(parent) { this->setAutoFillBackground(true);//覆盖 this->resize(480,270); this->setWindowIcon(QIcon("img/icon.jpg")); this->setWindowTitle("贪吃蛇"); QPalette palette; palette.setBrush(QPalette::Background,QBrush((QPixmap)"img/bjt.png")); this->setPalette(palette); //按扭区 leftbtn=new QPushButton(this); leftbtn->setIcon((QIcon)"img/zuo.png"); leftbtn->setIconSize(QSize(40,40)); leftbtn->setGeometry(QRect(340,180,40,40)); leftbtn->setFlat(true); rightbtn=new QPushButton(this); rightbtn->setIcon((QIcon)"img/you.png"); rightbtn->setIconSize(QSize(40,40)); rightbtn->setGeometry(QRect(430,180,40,40)); rightbtn->setFlat(true

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 696518资源总数
  • 104269会员总数
  • 31今日下载