Qt文件读取之QFile
来源:互联网 发布:广西网络爱情诈骗团伙 编辑:程序博客网 时间:2024/05/12 23:23
Qt提供了QFile类来进行文件处理,为了更方便地处理文本文件或二进制文件,Qt还提了QTextStream类和QDataStream类,
QFile file(fileName);
if(!file.open(QFile::WriteOnly|QFile::Text))//以只写方式打开文件,如果打开失败则弹出提示框并返回
{
QMessageBox::warning(this,tr("保存文件"),tr("无法保存文件 %1:\n %2").arg(fileName).arg(file.errorString()));
//%1,%2表示后面的两个arg参数的值,在""中会将变量当作普通字符串处理
return false;
}
QTextStream out(&file);
out<<ui->textEdit->toPlainText();//将文本编辑器里的内容以纯文本的形式输出到流对象中
QTextStream in(&file);
ui->textEdit->setText(in.readAll()); //将文件中的所有内容都写到文本编辑器中
- Qt文件读取之QFile
- Qt之文件操作 QFile
- 【转】Qt之文件操作 QFile
- 【转】Qt之文件操作 QFile
- Qt之文件操作QFile于QFileInfo
- QT之QFile
- Qfile文件读取以及写入
- QT QFile删除文件失败
- Qt拷贝文件、文件夹(QFile::copy)
- Qt拷贝文件、文件夹(QFile::copy)
- Qt拷贝文件、文件夹(QFile::copy)
- 笔记:Qt中的QFile(读写文件)
- Qt中读写文件的内容-------QFile
- Qt拷贝文件、文件夹(QFile::copy)
- 在linux下用qt打开或直接读取文件及其中的问题!(system(),qfile,qprocess)
- Qt学习之路之QFile读写文本文件
- Qt:QFile类实例源代码(读写文件)
- QT小程序:QFile
- JSP运行机制浅析
- java.lang.IllegalArgumentException: column '_id' does not exist
- gridView分页控件
- IE vs Chrome
- CSS 半透明
- Qt文件读取之QFile
- qulification、come into effect、go back on our word、ensure、be charged for、the view
- 关于Android的nodpi,xhdpi,hdpi,mdpi,ldpi
- unable to open an initial console
- openstudy网站
- Qt版文本编辑器注意细节
- mysql 基本导入导出命令
- Quake 2 BSP File Format
- 127 - "Accordian" Patience***