wobuku-ChineseChess-master【象棋】

 

 

开场动画

 

QSplashScreen *splash = new QSplashScreen;

splash->setPixmap(QPixmap(":/images/成信大冬.jpg"));

splash->show();

for(int i=0;i<2000;i++)

{

splash->repaint();

}

splash->setPixmap(QPixmap(":/images/成信大秋.jpg"));

splash->show();

for(int i=0;i<2000;i++)

{

splash->repaint();

}

splash->setPixmap(QPixmap(":/images/成信大夏.jpg"));

splash->show();

for(int i=0;i<2000;i++)

{

splash->repaint();

}

splash->setPixmap(QPixmap(":/images/成信大春.jpg"));

splash->show();

for(int i=0;i<2000;i++)

{

splash->repaint();

}

delete splash;

获取当前路径创建文件夹和文本文件

 

#include "BuildFile.h"

#include <QTextStream>

#include <QDateTime>

 

 

 

void buildFile()//建立存放数据的文件

{

QString infoPath = QDir::currentPath();

infoPath = infoPath + "/info";

QDir dirs;

dirs.mkpath(infoPath); //创建目录

QString name1 = infoPath + "/nickName.txt";

QString name2 = infoPath + "/userName.txt";

QString passWord = infoPath + "/passWord.txt";

QString age = infoPath + "/age.txt";

QString sex = infoPath + "/sex.txt";

QString registTime = infoPath + "/registTime.txt";

 

QFile file;

//程序第一次运行时初始化数据

if (!file.exists(name1))

{

QFile newFile(name1);

newFile.open(QIODevice::WriteOnly);

QTextStream name1IO(&newFile);

QString model("爱编程");

model = model + " ";

name1IO << model;

newFile.close();

}

if (!file.exists(name2))

{

QFile newFile(name2);

newFile.open(QIODevice::WriteOnly);

QTextStream name1IO(&newFile);

name1IO << 20160000 << " ";

newFile.close();

}

if (!file.exists(passWord))

{

QFile newFile(passWord);

newFile.open(QIODevice::WriteOnly);

QTextStream name1IO(&newFile);

name1IO << "10086" << " ";

newFile.close();

}

if (!file.exists(age))

{

QFile newFile(age);

newFile.open(QIODevice::WriteOnly);

QTextStream name1IO(&newFile);

name1IO << "18" << " ";

newFile.close();

}

if (!file.exists(registTime))

{

QFile newFile(registTime);

newFile.open(QIODevice::WriteOnly);

QTextStream name1IO(&newFile);

QDateTime time = QDateTime::currentDateTime();

QString str = time.toString("yyyy-MM-dd");

name1IO << str << " ";

newFile.close();

}

if (!file.exists(sex))

{

QFile newFile(sex);

newFile.open(QIODevice::WriteOnly);

QTextStream name1IO(&newFile);

QString model("女");

model = model + " ";

name1IO << model;

newFile.close();

}

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

注册信息记录和读取

单独创建一个类,使用这个类记录注册信息

读取文本文件;

 

class infoModel : public QAbstractTableModel

{

Q_OBJECT

public:

QList<QString> nickName;

QList<QString>::iterator iter1;

QList<int> userName;

QList<QString> password;

QList<QString>::iterator iter2;

QList<int> age;

QList<QString> sex;

QList<QString> registTime;

QVector<QString> info;

 

修改密码

 

游戏界面(支持退后一步)

 

开场动画

 

 

开场动画

 

 

原文地址:https://www.cnblogs.com/tangyuanjie/p/14028242.html