在嵌入式开发中,如果需要记录一些数据,比如血压,血糖、心率等等,这些都是智能医疗设备所测量的数据。我们有几种方法来实现数据的存储:存放在内存中,存放在内存卡中。如果采用了嵌入式系统,那么可以建立一个文件来进行数据的存储。要创建一个文件,首先要在指定的位置进行文档的创建,那么在QT中我们采用QDir进行路径的判断。
本节课介绍一下QT文件的创建和内容的编写。
首先看源文件:
#include <QCoreApplication>
#include <QtDebug>
#include <QDir>
#include <QString>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// QString mStr = "hello,www.eepw.com.cn";
QDir Mkpath;
QString myPath="/home/mjl/QT_exam/lesson2/data";
if( !Mkpath.exists(myPath))
{
Mkpath.mkpath(myPath);
qDebug() << Mkpath.exists(myPath);
}
return a.exec();
}
我要赚赏金
