/*************************************************
* QIODevice::ReadWrite 可读写
* QIODevice::Text 换行符生效
* QIODevice::Append 追加写入
* QFile::Truncate 表示将原文件清空
**************************************************/
https://blog.csdn.net/hebbely/article/details/58060601?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-1-58060601.nonecase&utm_term=qtextstream%E8%BF%BD%E5%8A%A0&spm=1000.2123.3001.4430
if(buttonNumber==9)
{
//存储数据
QString fileNameIndexStr = QString::number(fileNameIndex);
QString fileName="C:/Users/Administrator/Desktop/QT_Host _Computer/dataStorageTest/"+fileNameIndexStr+".txt";
QFile data(fileName);
buttonNumber=1;//这里提示一下结束了一轮的数据采集
//fileNameIndex++;
/*************************************************
* QIODevice::ReadWrite 可读写
* QIODevice::Text 换行符生效
* QIODevice::Append 追加写入
* QFile::Truncate 表示将原文件清空
**************************************************/
if(data.open(QFile::WriteOnly|QFile::Text|QFile::Append))
{
QTextStream out(&data);
QString strPos="("+QString::number(event->x())+","+QString::number(event->y())+")";
//out<<QObject::tr("score1:")<<qSetFieldWidth(0)<<left<<90<<endl;
out<<QObject::tr("%start")<<qSetFieldWidth(0)<<left<<' '<<endl;
out<<QObject::tr("Pos:")<<qSetFieldWidth(0)<<left<<strPos<<endl;
out<<QObject::tr("Time:")<<qSetFieldWidth(0)<<left<<strTime+'\n'<<endl;
}
}
QString strDebug="buttton"+QString ::number(buttonNumber)+"1 was clicked!";
qDebug()<<strDebug;
ui->label->setText(QString::number(buttonNumber));