QT翻金币案例教程
1、在.pro文件中添加如下代码
QT+=multimedia//主要用于后期调用QSound库
2、使用QT提供的Mainwindow类编写主要场景界面
头文件如下
#ifndef MAINSCENE_H
#define MAINSCENE_H
#include
#include<chooselevelscene.h>
QT_BEGIN_NAMESPACE
namespace Ui { class MainScene; }
QT_END_NAMESPACE
class MainScene : public QMainWindow
{
Q_OBJECT
public:
MainScene(QWidget *parent = nullptr);
~MainScene();
void paintEvent(QPaintEvent *);
ChooseLevelScene *chooseScene;
private:
Ui::MainScene *ui;
};
#endif // MAINSCENE_H
具体实现代码内容
#include “mainscene.h”
#include “ui_mainscene.h”
#include
#include
#include
#include<mypushbutton.h>
MainScene::MainScene(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainScene)
{
ui->setupUi(this);
QSound *startSound=new QSound(":/TapButtonSound.wav",this);
//退出游戏
connect(ui->actionquite,&QAction::triggered,this,={
this->close();
});
//设置固定大小
this->setFixedSize(320,588);
//设置标题
this->setWindowTitle(“小陈带你翻金币”);
//
this->setWindowIcon(QPixmap(":/Coin0001.png"));
MyPushButton *starbtn=new MyPushButton(":/MenuSceneStartButton.png");
starbtn->setParent(this);
starbtn->move(this->width()*0.5 - starbtn->width()*0.5,this->height()*0.7);
chooseScene =new ChooseLevelScene();
//监听返回信号
connect(chooseScene,&ChooseLevelScene::chooseSceneBack,={
//第二场景隐藏
chooseScene->hide();
//
//自身位置同步为关卡场景位置
this->setGeometry(chooseScene->geometry());
//
//主场景显示
this->show();
//
});
connect(starbtn,&MyPushButton::clicked,={
startSound->play();
starbtn->zoom1();
starbtn->zoom2();
//延时进入下一场景
QTimer::singleShot(500,this,={
//隐藏主界面
this->hide();
//
//设置关卡场景位置
chooseScene->setGeometry(this->geometry());
//
//显示
chooseScene->show();
//
});
});
}
void MainScene::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QPixmap pix;
pix.load(":/PlayLevelSceneBg.png");
painter.drawPixmap(0,0,320,588,pix);
pix.load(":/Title.png");
pix=pix.scaled(pix.width()*0.6,pix.height()*0.6);
painter.drawPixmap(10,30,pix.width(),pix.height(),pix);
}
MainScene::~MainScene()
{
delete ui;
}
3、自定义按钮类
主要使用QMainWindow设置最开始的状态,创建完成后将继承的父类从QMainWindow改为QPushButton
具体代码如下
将原有的QMainWindow改为QPushButton
头文件:
#ifndef MYPUSHBUTTON_H
#define MYPUSHBUTTON_H
#include <QPushButton>
class MyPushButton : public QPushButton
{
Q_OBJECT
public:
//explicit MyPushButton(QWidget *parent = nullptr);
MyPushButton(QString normalImg,QString pressImg="");
//数据保存
QString normalImgPath;
QString pressedImgPath;
//跳跃动画
void zoom1();
void zoom2();
//鼠标按下,释放事件
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
signals:
};
#endif // MYPUSHBUTTON_H
资源代码:
#include "mypushbutton.h"
#include
#include
MyPushButton::MyPushButton(QString normalImg,QString pressImg)
{
this->normalImgPath=normalImg;
this->pressedImgPath=pressImg;
QPixmap pix;
bool ret=pix.load(this->normalImgPath);
if(!ret)
{
QString str=QString("%1 加载失败").arg(this->normalImgPath);
qDebug()<<str;
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 *animation1=new QPropertyAnimation(this,“geometry”);
//设置间隔,毫秒
animation1->setDuration(200);
//起始位置
animation1->setStartValue(QRect(this->x(),this->y(),this->width(),this->height()));
//结束位置
animation1->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
//缓和曲线
animation1->setEasingCurve(QEasingCurve::OutBounce);
//执行动画
animation1->start();
}
void MyPushButton::zoom2()
{
QPropertyAnimation *animation1=new QPropertyAnimation(this,“geometry”);
animation1->setDuration(200);
animation1->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
animation1->setEndValue(QRect(this->x(),this->y(),this->width(),this->height()));
animation1->setEasingCurve(QEasingCurve::OutBounce);
animation1->start();
}
void MyPushButton::mousePressEvent(QMouseEvent *e)
{
//传入的图片路径不为空
if(this->pressedImgPath!="")
{
QPixmap pix;
bool ret=pix.load(this->pressedImgPath);
if(!ret)
{
qDebug()<<“加载失败”;
}
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet(“QPushButton{border:0px;}”);
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
}
//其他事件
QPushButton::mousePressEvent(e);
}
void MyPushButton::mouseReleaseEvent(QMouseEvent *e)
{
//传入的图片路径不为空
if(this->pressedImgPath!="")
{
QPixmap pix;
bool ret=pix.load(this->normalImgPath);
if(!ret)
{
qDebug()<<“加载失败”;
}
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet(“QPushButton{border:0px;}”);
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
}
//其他事件
QPushButton::mouseReleaseEvent(e);
}
4、硬币类的制作:采用和3相同的方法,自QPushButton继承
头文件:
#ifndef MYCOIN_H
#define MYCOIN_H
#include
class MyCoin : public QPushButton
{
Q_OBJECT
public:
//explicit MyCoin(QWidget *parent = nullptr);
MyCoin(QString CoinImg);//CoinImg显示金币或银币
void changeFlag();
void mousePressEvent(QMouseEvent *e);
QTimer *timer1;
QTimer *timer2;
int min=1;
int max=8;
int posX;//x坐标
int posY;//y坐标
bool flag;//正反标志
bool isAnimation=false;//翻转动画标志
bool isWin=false;
signals:
};
#endif // MYCOIN_H
资源文件:
#include “mycoin.h”
#include
#include
#include
MyCoin::MyCoin(QString CoinImg)
{
QPixmap pix;
bool ret=pix.load(CoinImg);
if(!ret)
{
QString str=QString(“图片加载失败%1”).arg(CoinImg);
QMessageBox::critical(this,“加载失败”,str);
return;
}
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet(“QPushButton{border:0px}”);
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
//构造定时器
timer1=new QTimer(this);
timer2=new QTimer(this);
//
//初始化按钮是否执行动画标志
isAnimation=false;
//
//监听定时器金币翻动
connect(timer1,&QTimer::timeout,[=](){
QPixmap pix;
QString str=QString(":/Coin000%1.png").arg(this->min++);
pix.load(str);
this->setFixedSize(pix.width(),pix.height());
this->setStyleSheet("QPushButton{border:0px}");
this->setIcon(pix);
this->setIconSize(QSize(pix.width(),pix.height()));
//显示到最后一张,停止定时器
if(this->min>this->max)
{
this->min=1;
isAnimation=false;
timer1->stop();
}
});
//监听银币翻动
connect(timer2,&QTimer::timeout,[=](){
QPixmap pix;
QString str=QString(":/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()));
//显示到最后一张,停止定时器
if(this->min>this->max)
{
this->max=8;
isAnimation=false;
timer2->stop();
}
});
}
void MyCoin::changeFlag()
{
if(this->flag)
{
//同步执行动画标志
isAnimation=true;
//开启正面翻反面定时器
timer1->start(30);
this->flag=false;
}
else
{
isAnimation=true;
timer2->start(30);
this->flag=true;
}
}
void MyCoin::mousePressEvent(QMouseEvent *e)
{
if(this->isAnimation||this->isWin)
{
//动画,不响应
return;
}
else
{
QPushButton::mousePressEvent(e);
}
}
5、chooselevelscene场景搭建
头文件:
#ifndef CHOOSELEVELSCENE_H
#define CHOOSELEVELSCENE_H
#include
#include"playscene.h"
class ChooseLevelScene : public QMainWindow
{
Q_OBJECT
public:
explicit ChooseLevelScene(QWidget *parent = nullptr);
//绘图事件
void paintEvent(QPaintEvent *);
PlayScene *playSence=NULL;
signals:
//信号只声明,不实现
void chooseSceneBack();
};
#endif // CHOOSELEVELSCENE_H
资源文件:
#include “chooselevelscene.h”
#include<mypushbutton.h>
#include
#include
#include
#include
#include
ChooseLevelScene::ChooseLevelScene(QWidget *parent) : QMainWindow(parent)
{
//设置固定大小
this->setFixedSize(320,588);
//设置标题
this->setWindowTitle(“选择关卡”);
//
this->setWindowIcon(QPixmap(":/Coin0001.png"));
//
//创建菜单栏
QMenuBar *bar=menuBar();
this->setMenuBar(bar);
QMenu *startMenu=bar->addMenu("开始");
//
QAction *quitAction=startMenu->addAction("新建");
connect(quitAction,&QAction::triggered,[=](){
this->close();
});
//创建返回按钮
MyPushButton *backBtn=new MyPushButton(":/BackButton.png",":/BackButtonSelected.png");
backBtn->setParent(this);
backBtn->move(this->width() - backBtn->width(),this->height() - backBtn->height());
connect(backBtn,&MyPushButton::clicked,[=](){
QTimer::singleShot(500,this,[=](){
emit this->chooseSceneBack();
});
});
//
playSence=NULL;
//
//关卡选择
for(int i=0;i<20;i++)
{
MyPushButton *menuBtn=new MyPushButton(":/LevelIcon.png");
menuBtn->setParent(this);
menuBtn->move(25+(i%4)*70,130+(i/4)*70);
QLabel *label=new QLabel(this);
//
connect(menuBtn,&MyPushButton::clicked,[=](){
//
this->hide();
//
//
playSence=new PlayScene(i+1);
//
//将游戏场景位置同步到选择关卡场景
playSence->setGeometry(this->geometry());
//
playSence->show();
//
connect(playSence,&PlayScene::chooseSceneBack,[=](){
//设置关卡位置为游戏场景返回时的位置
this->setGeometry(playSence->geometry());
//
//具体场景隐藏
playSence->close();
delete playSence;
playSence=NULL;
//选择关卡场景 显示
this->show();
//
});
});
//设置标签大小
label->setFixedSize(menuBtn->width(),menuBtn->height());
//显示标签
label->setText(QString::number(i+1));
label->move(25+(i%4)*70,130+(i/4)*70);
label->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
//对标签设置鼠标穿透
label->setAttribute(Qt::WA_TransparentForMouseEvents);
}
}
void ChooseLevelScene::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QPixmap pix;
pix.load(":/OtherSceneBg.png");
painter.drawPixmap(0,0,this->width(),this->height(),pix);
//标题
pix.load(":/Title.png");
painter.drawPixmap((this->width() - pix.width())*0.5,30,pix.width(),pix.height(),pix);
}
6、playscenen场景
头文件:#ifndef PLAYSCENE_H
#define PLAYSCENE_H
#include
#include"mycoin.h"
class PlayScene : public QMainWindow
{
Q_OBJECT
public:
//explicit PlayScene(QWidget *parent = nullptr);
PlayScene(int index);
int levallindex;
void paintEvent(QPaintEvent *);
//金币银币标志
int gameArray[4][4];
MyCoin *coinBtn[4][4];
bool isWin=false;
int x=0;
signals:
void chooseSceneBack();
};
#endif // PLAYSCENE_H
资源文件:
#include “playscene.h”
#include"mypushbutton.h"
#include"mycoin.h"
#include"dataconfig.h"
#include
#include
#include
#include
#include
#include
#include
/*PlayScene::PlayScene(QWidget *parent) : QMainWindow(parent)
{
}
*/
PlayScene::PlayScene(int index)
{
QTimer *timer=new QTimer(this);
timer->start(1000);
QLabel *timelabel=new QLabel(this);
connect(timer,&QTimer::timeout,={
QString str1=QString(“Time:”);
QString str2=QString::number(x);
str1+=str2;
timelabel->setText(str1);
x++;
});
QString strl=“Time”;
timelabel->setText(“Time”);
timelabel->move(225,408);
levallindex=index;
this->setFixedSize(310,588);
//设置标题
this->setWindowTitle(“选择关卡”);
//
this->setWindowIcon(QPixmap(":/Coin0001.png"));
//
//创建菜单栏
QMenuBar *bar=menuBar();
this->setMenuBar(bar);
QMenu *startMenu=bar->addMenu("开始");
//
//关闭Action
QAction *quitAction=startMenu->addAction("新建");
connect(quitAction,&QAction::triggered,[=](){
this->close();
});
//胜利音效设置
QSound *winsound=new QSound(":/LevelWinSound.wav");
//
//翻动硬币的音效
QSound *changesound=new QSound(":/ConFlipSound.wav");
//
//创建返回按钮
MyPushButton *backBtn=new MyPushButton(":/BackButton.png",":/BackButtonSelected.png");
backBtn->setParent(this);
backBtn->move(this->width() - backBtn->width(),this->height() - backBtn->height());
connect(backBtn,&MyPushButton::clicked,[=](){
QTimer::singleShot(500,this,[=](){
emit this->chooseSceneBack();
});
});
//
//显示具体关卡
QLabel *label=new QLabel;
label->setParent(this);
QString str=QString("Leave: %1").arg(this->levallindex);
QFont font;
//
font.setFamily("华文新魏");
font.setPointSize(20);
//
label->setFont(font);
label->setText(str);
label->setGeometry(QRect(30,this->height()-50,160,50));
//
dataConfig data;
//初始化游戏中的二维数组
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
this->gameArray[i][j]=data.mData[this->levallindex][i][j];
}
}
//
//创建胜利效果图
QLabel *winlabel=new QLabel;
QPixmap pix;
pix.load(":/LevelCompletedDialogBg.png");
winlabel->setGeometry(QRect(0,0,pix.width(),pix.height()));
winlabel->setParent(this);
winlabel->setPixmap(pix);
winlabel->move((this->width() - pix.width())*0.5,-pix.height());
//
//创建金币背景图片
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
QLabel *bg=new QLabel;
bg->setGeometry(0,0,50,50);
bg->setPixmap(QPixmap(":/BoardNode(1).png"));
bg->setParent(this);
bg->move(57+i*50,200+j*50);
//创建金币
QString str;
if(this->gameArray[i][j]==1)
{
//金币
str=":/Coin0001.png";
}
else
{
str=":/Coin0008.png";
}
MyCoin *coin=new MyCoin(str);
coin->posX=i;//x
coin->posY=j;//y
coin->flag=this->gameArray[i][j];
coin->setParent(this);
coin->move(59+i*50,204+j*50);
//将coin放入到维护的金币的二维数组中
coinBtn[i][j]=coin;
//
//翻动金币的信号监听
connect(coin,&MyPushButton::clicked,[=](){
//暂时禁用按钮,解决bug
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
this->coinBtn[i][j]->isWin=false;
}
}
//
coin->changeFlag();
changesound->play();
//同步维护内部二维数组
gameArray[i][j]=gameArray[i][j]==0?1:1;
QTimer::singleShot(200,this,[=](){
//继续翻动周围的硬币
//右侧
if(coin->posX+1<=3)
{
coinBtn[coin->posX+1][coin->posY]->changeFlag();
gameArray[coin->posX+1][coin->posY]=gameArray[coin->posX+1][coin->posY]==0?1:1;
}
//左侧
if(coin->posX-1>=0)
{
coinBtn[coin->posX-1][coin->posY]->changeFlag();
gameArray[coin->posX-1][coin->posY]=gameArray[coin->posX-1][coin->posY]==0?1:1;
}
//下侧
if(coin->posY+1<=3)
{
coinBtn[coin->posX][coin->posY+1]->changeFlag();
gameArray[coin->posX][coin->posY+1]=gameArray[coin->posX][coin->posY+1]==0?1:1;
}
//上侧
if(coin->posY-1>=0)
{
coinBtn[coin->posX][coin->posY-1]->changeFlag();
gameArray[coin->posX][coin->posY-1]=gameArray[coin->posX][coin->posY-1]==0?1:1;
}
//
//判断胜利
this->isWin=true;
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
if(coinBtn[i][j]->flag==false)
{
isWin=false;
break;
}
}
}
if(this->isWin==true)
{
//将所有硬币的胜利标志设置为true
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
coinBtn[i][j]->isWin=true;
}
}
timer->stop();
//将胜利图片显示出来
QPropertyAnimation *animation=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()+114,winlabel->width(),winlabel->height()));
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
winsound->play();
}
});
});
}
}
//
}
void PlayScene::paintEvent(QPaintEvent *)
{
//画背景
QPainter painter(this);
QPixmap pix;
pix.load(":/PlayLevelSceneBg.png");
painter.drawPixmap(0,0,this->width(),this->height(),pix);
//
//标题
pix.load(":/Title.png");
pix=pix.scaled(pix.width()*0.5,pix.height()*0.5);
painter.drawPixmap(10,30,pix.width(),pix.height(),pix);
}
7、游戏内部关卡难度设置
采用map这一结构存储各关关卡,需要熟练使用STL
代码如下
.h文件:
#ifndef DATACONFIG_H
#define DATACONFIG_H
#include
#include
#include
class dataConfig : public QObject
{
Q_OBJECT
public:
explicit dataConfig(QObject *parent=0);
QMap<int,QVector<QVector<int>>>mData;
signals:
public slots:
};
#endif// DATACINFIG_H
.cpp:
#include"dataconfig.h"
#include
dataConfig::dataConfig(QObject *parent) : QObject(parent)
{
int array1[4][4]={{1,1,1,1},
{1,1,0,1},
{1,0,0,0},
{1,1,0,1}};
QVector<QVector> v;
for(int i=0;i<4;i++)
{
QVector v1;
for(int j=0;j<4;j++)
{
v1.push_back(array1[i][j]);
}
v.push_back(v1);
}
mData.insert(1,v);
int array2[4][4]={{1,0,1,1},{0,0,1,1},{1,1,0,0},{1,1,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array2[i][j]);
}
v.push_back(v1);
}
mData.insert(2,v);
int array3[4][4]={{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array3[i][j]);
}
v.push_back(v1);
}
mData.insert(3,v);
int array4[4][4]={{0,1,1,1},{1,0,0,1},{1,0,1,1},{1,1,1,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array4[i][j]);
}
v.push_back(v1);
}
mData.insert(4,v);
int array5[4][4]={{1,0,0,1},{0,0,0,0},{0,0,0,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array5[i][j]);
}
v.push_back(v1);
}
mData.insert(5,v);
int array6[4][4]={{1,1,1,1},{0,0,0,0},{0,0,0,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array6[i][j]);
}
v.push_back(v1);
}
mData.insert(6,v);
int array7[4][4]={{1,0,0,1},{1,1,1,1},{0,1,1,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array7[i][j]);
}
v.push_back(v1);
}
mData.insert(7,v);
int array8[4][4]={{1,0,0,1},{1,1,1,1},{1,1,1,1},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array8[i][j]);
}
v.push_back(v1);
}
mData.insert(8,v);
int array9[4][4]={{0,0,0,0},{1,1,1,1},{0,1,1,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array9[i][j]);
}
v.push_back(v1);
}
mData.insert(9,v);
int array10[4][4]={{1,0,1,0},{1,1,1,1},{0,1,1,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array10[i][j]);
}
v.push_back(v1);
}
mData.insert(10,v);
int array11[4][4]={{0,0,1,0},{1,1,1,0},{0,1,1,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array11[i][j]);
}
v.push_back(v1);
}
mData.insert(11,v);
int array12[4][4]={{0,0,1,1},{0,0,1,1},{0,1,1,0},{1,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array12[i][j]);
}
v.push_back(v1);
}
mData.insert(12,v);
int array13[4][4]={{0,1,1,0},{0,0,0,0},{0,0,0,0},{0,1,1,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array13[i][j]);
}
v.push_back(v1);
}
mData.insert(13,v);
int array14[4][4]={{1,0,0,1},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array14[i][j]);
}
v.push_back(v1);
}
mData.insert(14,v);
int array15[4][4]={{1,1,0,1},{0,0,1,0},{0,0,1,0},{0,0,0,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array15[i][j]);
}
v.push_back(v1);
}
mData.insert(15,v);
int array16[4][4]={{1,1,0,1},{0,0,1,0},{0,0,1,0},{1,1,1,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array16[i][j]);
}
v.push_back(v1);
}
mData.insert(16,v);
int array17[4][4]={{0,1,1,1},{0,1,0,0},{0,0,1,0},{1,1,1,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array17[i][j]);
}
v.push_back(v1);
}
mData.insert(17,v);
int array18[4][4]={{0,0,0,1},{0,0,1,0},{0,1,0,0},{1,0,0,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array18[i][j]);
}
v.push_back(v1);
}
mData.insert(18,v);
int array19[4][4]={{0,1,0,0},{0,1,1,0},{0,0,1,1},{0,0,0,1}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array19[i][j]);
}
v.push_back(v1);
}
mData.insert(19,v);
int array20[4][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
v.clear();
for(int i=0;i<4;i++)
{
QVector<int> v1;
for(int j=0;j<4;j++)
{
v1.push_back(array20[i][j]);
}
v.push_back(v1);
}
mData.insert(20,v);
}