热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

08翻金币游戏

mianscene类:游戏的开始界面mypushbutton类:为开始按钮和返回按钮封装的无边框的按钮控件chooselevelscene类

mianscene类:游戏的开始界面

mypushbutton类:为开始按钮和返回按钮封装的无边框的按钮控件

chooselevelscene类:选择游戏关卡的界面

playscene类:游戏的出场景

mycoin类:为金币封装的按钮

dataconfig类:游戏配置类

 


mainscene.h

#ifndef MAINSCENE_H
#define MAINSCENE_H#include
#include "chooselevelscene.h"namespace Ui {
class MainScene;
}class MainScene : public QMainWindow
{Q_OBJECTpublic:explicit MainScene(QWidget *parent = 0);~MainScene();void paintEvent(QPaintEvent *event);ChooseLevelScene *chooseScene = NULL;private:Ui::MainScene *ui;
};#endif // MAINSCENE_H

mainscene.cpp

#include "mainscene.h"
#include "ui_mainscene.h"
#include
#include "mypushbutton.h"
#include
#include
#include MainScene::MainScene(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainScene)
{ui->setupUi(this);//配置主场景//设置固定大小setFixedSize(320,588);//设置图标setWindowIcon(QIcon(":/res/Coin0001.png"));//设置标题setWindowTitle("翻金币主场景");connect(ui->actionquit, &QAction::triggered, [=](){this->close();});//开始音效QSound *startSound = new QSound(":/res/TapButtonSound.wav", this);//开始按钮MyPushButton *startBtn = new MyPushButton(":/res/MenuSceneStartButton.png");startBtn->setParent(this);startBtn->move(this->width() * 0.5 - startBtn->width() * 0.5, this->height() * 0.7);//实例化选择关卡场景this->chooseScene = new ChooseLevelScene;//监听选择关卡的信号//监听代码要写在这里,不然没点击一次开始按钮就会执行一次connect(chooseScene, &ChooseLevelScene::chooseSceneBack, this, [=](){this->setGeometry(chooseScene->geometry());chooseScene->hide();this->show();});connect(startBtn, &MyPushButton::clicked, [=](){
// qDebug() <<"点击了开始按钮";//播放开始音效资源startSound->play();startBtn->zoom1();startBtn->zoom2();//延时进入到选择关卡中QTimer::singleShot(500, this, [&#61;](){//设置chooseScene场景的位置chooseScene->setGeometry(this->geometry());//自身隐藏this->hide();//显示chooseScene->show();});});
}void MainScene::paintEvent(QPaintEvent *event) {QPainter painter(this);QPixmap pix;pix.load(":/res/PlayLevelSceneBg.png");//自适应painter.drawPixmap(0, 0, this->width(), this->height(), pix);//画背景上的图标pix.load(":/res/Title.png");pix &#61; pix.scaled(pix.width() *0.5, pix.height()*0.5);painter.drawPixmap(10,30,pix);}MainScene::~MainScene()
{delete ui;
}

mypushbutton.h

#ifndef MYPUSHBUTTON_H
#define MYPUSHBUTTON_H#include class MyPushButton : public QPushButton
{Q_OBJECT
public:
// explicit MyPushButton(QWidget *parent &#61; nullptr);MyPushButton(QString normalImg, QString pressImg &#61; "");QString nornalImgPath;QString PressImgPath;void mousePressEvent(QMouseEvent *e);void mouseReleaseEvent(QMouseEvent *e);//弹跳特效void zoom1(); //向下跳void zoom2(); //向上跳signals:public slots:
};#endif // MYPUSHBUTTON_H

mypushbutton.cpp

#include "mypushbutton.h"
#include
#include MyPushButton::MyPushButton(QString normalImg, QString pressImg) {this->nornalImgPath &#61; normalImg;this->PressImgPath &#61; pressImg;QPixmap pix;bool ret &#61; pix.load(normalImg);if (!ret) {qDebug() <<"图片加载失败";return;}//设置图片固定大小this->setFixedSize(pix.width(), pix.height());//设置不规则图片样式this->setStyleSheet("QPushButton{border:0px}");//设置图标this->setIcon(pix);//设置图标大小this->setIconSize(QSize(pix.width(), pix.height()));
}
void MyPushButton::zoom1() {//创建动态对象QPropertyAnimation *animation &#61; new QPropertyAnimation(this, "geometry");//设置动画的时间间隔animation->setDuration(200);//起始位置animation->setStartValue(QRect(this->x(), this->y(), this->width(), this->height()));//结束为止animation->setEndValue(QRect(this->x(), this->y()&#43;10, this->width(), this->height()));//设置弹跳曲线animation->setEasingCurve(QEasingCurve::OutBounce);//执行动画animation->start();
}void MyPushButton::zoom2() {//创建动态对象QPropertyAnimation *animation &#61; new QPropertyAnimation(this, "geometry");//设置动画的时间间隔animation->setDuration(200);//起始位置animation->setStartValue(QRect(this->x(), this->y()&#43;10, this->width(), this->height()));//结束为止animation->setEndValue(QRect(this->x(), this->y(), this->width(), this->height()));//设置弹跳曲线animation->setEasingCurve(QEasingCurve::OutBounce);//执行动画animation->start();
}void MyPushButton::mousePressEvent(QMouseEvent *e) {if(this->PressImgPath !&#61; "") {QPixmap pix;bool ret &#61; pix.load(this->PressImgPath);if (!ret) {qDebug() <<"图片加载失败";return;}//设置图片固定大小this->setFixedSize(pix.width(), pix.height());//设置不规则图片样式this->setStyleSheet("QPushButton{border:0px}");//设置图标this->setIcon(pix);//设置图标大小this->setIconSize(QSize(pix.width(), pix.height()));}//让父类执行其他的内容return QPushButton::mousePressEvent(e);
}void MyPushButton::mouseReleaseEvent(QMouseEvent *e) {if(this->PressImgPath !&#61; "") {QPixmap pix;bool ret &#61; pix.load(this->nornalImgPath);if (!ret) {qDebug() <<"图片加载失败";return;}//设置图片固定大小this->setFixedSize(pix.width(), pix.height());//设置不规则图片样式this->setStyleSheet("QPushButton{border:0px}");//设置图标this->setIcon(pix);//设置图标大小this->setIconSize(QSize(pix.width(), pix.height()));}//让父类执行其他的内容return QPushButton::mouseReleaseEvent(e);
}
//MyPushButton::MyPushButton(QWidget *parent) : QPushButton(parent)
//{//}

chooselevelscene.h

#ifndef CHOOSELEVELSCENE_H
#define CHOOSELEVELSCENE_H#include
#include class ChooseLevelScene : public QMainWindow
{Q_OBJECT
public:explicit ChooseLevelScene(QWidget *parent &#61; nullptr);void paintEvent(QPaintEvent *event);//游戏场景指针PlayScene *play &#61; NULL;signals:void chooseSceneBack();
public slots:
};#endif // CHOOSELEVELSCENE_H

chooselevelscene.cpp

#include "chooselevelscene.h"
#include
#include
#include "mypushbutton.h"
#include
#include
#include
#include ChooseLevelScene::ChooseLevelScene(QWidget *parent) : QMainWindow(parent)
{this->setFixedSize(320, 588);this->setWindowIcon(QPixmap(":/res/Coin0001.png"));this->setWindowTitle("选择关卡场景");QMenuBar *bar &#61; menuBar();setMenuBar(bar);QMenu *startMenu &#61; bar->addMenu("开始");QAction *quitAction &#61; startMenu->addAction("退出");connect(quitAction, &QAction::triggered, [&#61;](){this->close();});//选择关卡音效QSound *chooseSound &#61; new QSound(":/res/TapButtonSound.wav", this);//返回按钮音效QSound *backSound &#61; new QSound(":/res/BackButtonSound.wav", this);//返回按钮MyPushButton *backBtn &#61; new MyPushButton(":/res/BackButton.png", ":/res/BackButtonSelected.png");backBtn->setParent(this);backBtn->move(this->width() - backBtn->width(), this->height() - backBtn->height());connect(backBtn, &MyPushButton::clicked, [&#61;](){
// qDebug() <<"点击了返回按钮";backSound->play();//延时返回QTimer::singleShot(200, this, [&#61;](){emit this->chooseSceneBack();});});//创建选择关卡的按钮for (int i &#61; 0; i <20; i&#43;&#43;) {MyPushButton *menuBtn &#61; new MyPushButton(":/res/LevelIcon.png");menuBtn->setParent(this);menuBtn->move(25 &#43; i%4 * 70, 130 &#43; i / 4 * 70);//监听每个按钮的点击事件connect(menuBtn, &MyPushButton::clicked, [&#61;](){chooseSound->play();QString str &#61; QString("您选择的是第 %1 关").arg(i &#43; 1);qDebug() <hide();this->play &#61; new PlayScene(i &#43; 1);//设置游戏场景的初始位置play->setGeometry(this->geometry());play->show();connect(play, &PlayScene::chooseSceneBack, [&#61;](){this->setGeometry(play->geometry());this->show();// 因为每关不一样&#xff0c;所以要delete掉比较好delete play;play &#61; NULL;});});QLabel *label &#61; new QLabel;label->setParent(this);label->setFixedSize(menuBtn->width(), menuBtn->height());label->setText(QString::number(i&#43;1));label->move(25 &#43; i%4 * 70, 130 &#43; i / 4 * 70);//设置 水平居中和垂直居中label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);//设置鼠标穿透 51号属性label->setAttribute(Qt::WA_TransparentForMouseEvents);}
}void ChooseLevelScene::paintEvent(QPaintEvent *event) {//加载背景QPainter painter(this);QPixmap pix;pix.load(":/res/OtherSceneBg.png");painter.drawPixmap(0, 0, this->width(), this->height(), pix);//加载标题pix.load(":/res/Title.png");painter.drawPixmap(this->width() * 0.5 - pix.width() * 0.5, 30, pix.width(), pix.height(), pix);
}

mycoin.h

#ifndef MYCOIN_H
#define MYCOIN_H#include
#include class MyCoin : public QPushButton
{Q_OBJECT
public:
// explicit MyCoin(QWidget *parent &#61; nullptr);//参数代表传入的是金币路径还是银币路径MyCoin(QString btnImg);//金币的属性int posX;int posY;//金币的正反面 正true 反falsebool flag;//改变标志的方法void changeFlag();QTimer *timer1;QTimer *timer2;int min &#61; 1;int max &#61; 8;//执行动画的标志&#xff0c;防止在未执行完动画的时候点击按钮bool isAnimation &#61; false;//重写按下 释放void mousePressEvent(QMouseEvent *e);//用于胜利后每个按钮停止翻转bool isWin &#61; false;signals:public slots:
};#endif // MYCOIN_H

mycoin.cpp

#include "mycoin.h"
#include MyCoin::MyCoin(QString btnImg) {QPixmap pix;bool ret &#61; pix.load(btnImg);if (!ret) {QString str&#61; QString("图片 %1 加载失败").arg(btnImg);qDebug() <setFixedSize(pix.width(), pix.height());this->setStyleSheet("QPushButton{border:0px;}");this->setIcon(pix);this->setIconSize(QSize(pix.width(), pix.height()));//初始化定时器对象this->timer1 &#61; new QTimer(this);this->timer2 &#61; new QTimer(this);connect(timer1, &QTimer::timeout, [&#61;](){QPixmap pix;QString str &#61; QString(":/res/Coin000%1.png").arg(this->min&#43;&#43;);pix.load(str);this->setFixedSize(pix.width(), pix.height());this->setStyleSheet("QPushButton{border:0px;}");this->setIcon(pix);this->setIconSize(QSize(pix.width(), pix.height()));//判断如果翻完了&#xff0c;将min重置为1if (this->min > this->max) {this->min &#61; 1;this->isAnimation &#61; false;timer1->stop();}});connect(timer2, &QTimer::timeout, [&#61;](){QPixmap pix;QString str &#61; QString(":/res/Coin000%1.png").arg(this->max--);pix.load(str);this->setFixedSize(pix.width(), pix.height());this->setStyleSheet("QPushButton{border:0px;}");this->setIcon(pix);this->setIconSize(QSize(pix.width(), pix.height()));//判断如果翻完了&#xff0c;将min重置为1if (this->max min) {this->max &#61; 8;this->isAnimation &#61; false;timer2->stop();}});
}void MyCoin::changeFlag() {if (this->flag) {timer1->start(30);this->isAnimation &#61; true;this->flag &#61; false;} else {timer2->start(30);this->isAnimation &#61; true;this->flag &#61; true;}
}void MyCoin::mousePressEvent(QMouseEvent *e) {if (this->isAnimation || this->isWin) { //胜利后屏蔽点击return;} else {QPushButton::mousePressEvent(e);}
}//MyCoin::MyCoin(QWidget *parent) : QPushButton(parent)
//{//}

playscene.h

#ifndef PLAYSCENE_H
#define PLAYSCENE_H#include
#include class PlayScene : public QMainWindow
{Q_OBJECT
public:
// explicit PlayScene(QWidget *parent &#61; nullptr);PlayScene(int levelNum);int levelIndex;void paintEvent(QPaintEvent *event);int gameArray[4][4];MyCoin *coinBtn[4][4];bool isWin;
signals:void chooseSceneBack();
public slots:
};#endif // PLAYSCENE_H

playscene.cpp

#include "playscene.h"
#include
#include
#include
#include "mypushbutton.h"
#include
#include
#include "mycoin.h"
#include "dataconfig.h"
#include
#include PlayScene::PlayScene(int levelNum) {QString str &#61; QString("进入了第 1% 关").arg(levelNum);qDebug() <levelIndex &#61; levelNum;//初始化游戏场景this->setFixedSize(320,588);this->setWindowIcon(QPixmap(":/res/Coin0001.png"));this->setWindowTitle("翻金币场景");//点击按钮 实现退出游戏QMenuBar *bar &#61; menuBar();setMenuBar(bar);QMenu *startMenu &#61; bar->addMenu("开始");QAction *quitAction &#61; startMenu->addAction("退出");connect(quitAction, &QAction::triggered, [&#61;](){this->close();});//添加音效QSound *backSound &#61; new QSound(":/res/BackButtonSound.wav", this);QSound *flipSound &#61; new QSound(":/res/ConFlipSound.wav", this);QSound *winSound &#61; new QSound(":/res/LevelWinSound.wav", this);//返回按钮MyPushButton *backBtn &#61; new MyPushButton(":/res/BackButton.png", ":/res/BackButtonSelected.png");backBtn->setParent(this);backBtn->move(this->width() - backBtn->width(), this->height() - backBtn->height());connect(backBtn, &MyPushButton::clicked, [&#61;](){qDebug() <<"返金币场景中点击了返回按钮";backSound->play();QTimer::singleShot(200, this, [&#61;](){emit this->chooseSceneBack();});});//显示当前的关卡数QLabel *label &#61; new QLabel;label->setParent(this);QFont font;font.setFamily("华文新魏");font.setPointSize(20);label->setFont(font);QString str1 &#61; QString("Level:%1").arg(this->levelIndex);label->setText(str1);label->setGeometry(30, this->height() - 50, 120, 50);//初始化每个关卡的二维数组dataConfig config;for (int i &#61; 0; i <4; i&#43;&#43;) {for (int j &#61; 0; j <4; j&#43;&#43;) {this->gameArray[i][j] &#61; config.mData[this->levelIndex][i][j];}}//胜利图片的显示QLabel *winLabel &#61; new QLabel;QPixmap pix;pix.load(":/res/LevelCompletedDialogBg.png");winLabel->setGeometry(0,0,pix.width(),pix.height());winLabel->setPixmap(pix);winLabel->setParent(this);winLabel->move((this->width() - pix.width()) * 0.5, -pix.height());//显示金币背景图案for (int i &#61; 0; i <4; i&#43;&#43;) {for (int j &#61; 0; j <4; j&#43;&#43;) {QPixmap pix &#61; QPixmap(":/res/BoardNode.png");QLabel *label &#61; new QLabel;label->setGeometry(0,0,pix.width(),pix.height()); //几何label->setPixmap(pix);label->setParent(this);label->move(57 &#43; i*50, 200 &#43; j*50);//创建金币if (this->gameArray[i][j] &#61;&#61; 1) {//显示金币str &#61; ":/res/Coin0001.png";} else {//显示银币str &#61; ":/res/Coin0008.png";}MyCoin *coin &#61; new MyCoin(str);coin->setParent(this);coin->move(59 &#43; i*50, 204 &#43; j*50);//给金币的属性赋值coin->posX &#61; i;coin->posY &#61; j;coin->flag &#61; this->gameArray[i][j]; //1正面 0反面//将金币放入金币的二维数组&#xff0c;以便后期的维护coinBtn[i][j] &#61; coin;//点击金币 进行翻转connect(coin, &MyCoin::clicked, [&#61;](){//点击后仅用所有金币,以防胜利时手快点击其他的按钮再进行无用的反转flipSound->play();for (int i &#61; 0; i <4; i&#43;&#43;) {for (int j &#61; 0; j <4; j&#43;&#43;) {this->coinBtn[i][j]->isWin &#61; true;}}coin->changeFlag();this->gameArray[i][j] &#61; this->gameArray[i][j] &#61;&#61; 0 ? 1 : 0;//翻转周围的金币&#xff0c;延时翻转QTimer::singleShot(300, this, [&#61;](){if (coin->posX &#43; 1 <&#61; 3) { //右侧//翻转coinBtn[coin->posX &#43; 1][coin->posY]->changeFlag();//维护正反面数组this->gameArray[coin->posX &#43; 1][coin->posY] &#61;this->gameArray[coin->posX &#43; 1][coin->posY] &#61;&#61; 0 ? 1 : 0;}if (coin->posX - 1 >&#61; 0) { //左侧coinBtn[coin->posX - 1][coin->posY]->changeFlag();this->gameArray[coin->posX - 1][coin->posY] &#61;this->gameArray[coin->posX - 1][coin->posY] &#61;&#61; 0 ? 1 : 0;}if (coin->posY &#43; 1 <&#61; 3) { //下侧coinBtn[coin->posX][coin->posY &#43; 1]->changeFlag();this->gameArray[coin->posX][coin->posY &#43; 1] &#61;this->gameArray[coin->posX][coin->posY &#43; 1] &#61;&#61; 0 ? 1 : 0;}if (coin->posY - 1 >&#61; 0) { //上侧coinBtn[coin->posX][coin->posY - 1]->changeFlag();this->gameArray[coin->posX][coin->posY - 1] &#61;this->gameArray[coin->posX][coin->posY - 1] &#61;&#61; 0 ? 1 : 0;}//翻转完成后解开禁用for (int i &#61; 0; i <4; i&#43;&#43;) {for (int j &#61; 0; j <4; j&#43;&#43;) {this->coinBtn[i][j]->isWin &#61; false;}}//判断是否胜利this->isWin &#61; true;for (int i &#61; 0; i <4; i&#43;&#43;) {for (int j &#61; 0; j <4; j&#43;&#43;) {if (coinBtn[i][j]->flag &#61;&#61; false) { //flag是coin中表示正反面的标志this->isWin &#61; false;break;}}}if (this->isWin &#61;&#61; true) {winSound->play();qDebug() <<"游戏胜利";for (int i &#61; 0; i <4; i&#43;&#43;) {for (int j &#61; 0; j <4; j&#43;&#43;) {coinBtn[i][j]->isWin &#61; true;}}//将胜利的图片移动下来QPropertyAnimation *animation &#61; new QPropertyAnimation(winLabel, "geometry");//设置时间间隔animation->setDuration(1000);//设置开始位置animation->setStartValue(QRect(winLabel->x(), winLabel->y(), winLabel->width(), winLabel->height()));//设置结束位置animation->setEndValue(QRect(winLabel->x(), winLabel->y()&#43;114, winLabel->width(), winLabel->height()));//设置缓和曲线animation->setEasingCurve(QEasingCurve::OutBounce);//执行动画animation->start();}});});}}
}void PlayScene::paintEvent(QPaintEvent *event) {QPainter painter(this);QPixmap pix;pix.load(":/res/PlayLevelSceneBg.png");painter.drawPixmap(0,0,this->width(),this->height(),pix);pix.load(":/res/Title.png");pix &#61; pix.scaled(pix.width()*0.5, pix.height()*0.5);painter.drawPixmap(10, 30, pix.width(), pix.height(), pix);
}//PlayScene::PlayScene(QWidget *parent) : QMainWindow(parent)
//{//}

dataconfig.h

#ifndef DATACONFIG_H
#define DATACONFIG_H#include
#include
#include class dataConfig : public QObject
{Q_OBJECT
public:explicit dataConfig(QObject *parent &#61; 0);public:QMap > >mData;signals:public slots:
};#endif // DATACONFIG_H

dataconfig.cpp

#include "dataconfig.h"
#include
dataConfig::dataConfig(QObject *parent) : QObject(parent)
{int array1[4][4] &#61; {{1, 1, 1, 1},{1, 1, 0, 1},{1, 0, 0, 0},{1, 1, 0, 1} } ;QVector> v;for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array1[i][j]);}v.push_back(v1);}mData.insert(1,v);int array2[4][4] &#61; { {1, 0, 1, 1},{0, 0, 1, 1},{1, 1, 0, 0},{1, 1, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array2[i][j]);}v.push_back(v1);}mData.insert(2,v);int array3[4][4] &#61; { {0, 0, 0, 0},{0, 1, 1, 0},{0, 1, 1, 0},{0, 0, 0, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array3[i][j]);}v.push_back(v1);}mData.insert(3,v);int array4[4][4] &#61; { {0, 1, 1, 1},{1, 0, 0, 1},{1, 0, 1, 1},{1, 1, 1, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array4[i][j]);}v.push_back(v1);}mData.insert(4,v);int array5[4][4] &#61; { {1, 0, 0, 1},{0, 0, 0, 0},{0, 0, 0, 0},{1, 0, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array5[i][j]);}v.push_back(v1);}mData.insert(5,v);int array6[4][4] &#61; { {1, 0, 0, 1},{0, 1, 1, 0},{0, 1, 1, 0},{1, 0, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array6[i][j]);}v.push_back(v1);}mData.insert(6,v);int array7[4][4] &#61; { {0, 1, 1, 1},{1, 0, 1, 1},{1, 1, 0, 1},{1, 1, 1, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array7[i][j]);}v.push_back(v1);}mData.insert(7,v);int array8[4][4] &#61; { {0, 1, 0, 1},{1, 0, 0, 0},{0, 0, 0, 1},{1, 0, 1, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array8[i][j]);}v.push_back(v1);}mData.insert(8,v);int array9[4][4] &#61; { {1, 0, 1, 0},{1, 0, 1, 0},{0, 0, 1, 0},{1, 0, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array9[i][j]);}v.push_back(v1);}mData.insert(9,v);int array10[4][4] &#61; { {1, 0, 1, 1},{1, 1, 0, 0},{0, 0, 1, 1},{1, 1, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array10[i][j]);}v.push_back(v1);}mData.insert(10,v);int array11[4][4] &#61; { {0, 1, 1, 0},{1, 0, 0, 1},{1, 0, 0, 1},{0, 1, 1, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array11[i][j]);}v.push_back(v1);}mData.insert(11,v);int array12[4][4] &#61; { {0, 1, 1, 0},{0, 0, 0, 0},{1, 1, 1, 1},{0, 0, 0, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array12[i][j]);}v.push_back(v1);}mData.insert(12,v);int array13[4][4] &#61; { {0, 1, 1, 0},{0, 0, 0, 0},{0, 0, 0, 0},{0, 1, 1, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array13[i][j]);}v.push_back(v1);}mData.insert(13,v);int array14[4][4] &#61; { {1, 0, 1, 1},{0, 1, 0, 1},{1, 0, 1, 0},{1, 1, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array14[i][j]);}v.push_back(v1);}mData.insert(14,v);int array15[4][4] &#61; { {0, 1, 0, 1},{1, 0, 0, 0},{1, 0, 0, 0},{0, 1, 0, 1}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array15[i][j]);}v.push_back(v1);}mData.insert(15,v);int array16[4][4] &#61; { {0, 1, 1, 0},{1, 1, 1, 1},{1, 1, 1, 1},{0, 1, 1, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array16[i][j]);}v.push_back(v1);}mData.insert(16,v);int array17[4][4] &#61; { {0, 1, 1, 1},{0, 1, 0, 0},{0, 0, 1, 0},{1, 1, 1, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array17[i][j]);}v.push_back(v1);}mData.insert(17,v);int array18[4][4] &#61; { {0, 0, 0, 1},{0, 0, 1, 0},{0, 1, 0, 0},{1, 0, 0, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array18[i][j]);}v.push_back(v1);}mData.insert(18,v);int array19[4][4] &#61; { {0, 1, 0, 0},{0, 1, 1, 0},{0, 0, 1, 1},{0, 0, 0, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array19[i][j]);}v.push_back(v1);}mData.insert(19,v);int array20[4][4] &#61; { {0, 0, 0, 0},{0, 0, 0, 0},{0, 0, 0, 0},{0, 0, 0, 0}} ;v.clear();for(int i &#61; 0 ; i <4;i&#43;&#43;){QVectorv1;for(int j &#61; 0 ; j <4;j&#43;&#43;){v1.push_back(array20[i][j]);}v.push_back(v1);}mData.insert(20,v);//测试数据
// for( QMap > >::iterator it &#61; mData.begin();it !&#61; mData.end();it&#43;&#43; )
// {
// for(QVector >::iterator it2 &#61; (*it).begin(); it2!&#61; (*it).end();it2&#43;&#43;)
// {
// for(QVector::iterator it3 &#61; (*it2).begin(); it3 !&#61; (*it2).end(); it3&#43;&#43; )
// {
// qDebug() <<*it3 ;
// }
// }
// qDebug() <// }}

 

 

 

 


推荐阅读
author-avatar
陳小勳2502936731
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有