QTextStream换行与追加写入
来源:互联网 发布:windows驱动开发视频 编辑:程序博客网 时间:2024/05/18 04:20
简述:
QTextStream可以操作QIODevice、QByteArray和QString,使用QTextStream的流操作符,可以方便读写单词、行和数字。
1、基本操作
QString csLogFile;QString runPath = QCoreApplication::applicationDirPath(); //csLogFile.clear();
csLogFile.append(tr("%1/LogFile_%2.txt").arg(runPath).arg(QDate::currentDate().toString("yyyyMMdd")));if (QString::compare(g_fLogFile->fileName(),csLogFile) != 0) {g_fLogFile->setFileName(csLogFile);
}
if(g_fLogFile->exists() && g_fLogFile->isOpen()){return 0;}
/************************************************** QIODevice::ReadWrite 可读写* QIODevice::Text 换行符生效* QIODevice::Append 追加写入* QFile::Truncate 表示将原文件清空**************************************************/if(g_fLogFile->open(QIODevice::Text | QIODevice::ReadWrite | QIODevice::Append)){
QTextStream out(g_fLogFile);out << QString("the answer is") <<endl;}
2、QTextStream的格式化函数
3、QTextStream的流操作符
1 0
- QTextStream换行与追加写入
- PHP fwrite 函数:将字符串写入文件(追加与换行)
- QTextStream不输出换行
- FileOutputStream类,实现换行写入和追加写入的解决办法
- IO流_FileOutputStream写出数据实现换行和追加写入
- IO流_FileOutputStream写出数据实现换行和追加写入
- Android追加换行写入内容到txt文件中
- IO流_FileOutputStream写出数据实现换行和追加写入
- 简单的-写入txt文本,追加写入与覆盖写入
- Qt使用Qtextstream进行换行操作
- 中文使用ofstream/wfstream/qtextstream写入
- QTextStream
- QTextStream
- Android中用FileWriter向SD卡写入文件时候如何在每行追加换行
- QTextStream流与QDataStream流
- Java 追加写入文件
- 追加写入txt
- hdfs文件追加写入
- WebService 简单入门教程(Java)
- sql server 2008怎么导出表中的结构和数据步骤
- Android WeakReference的理解与使用
- ffmpeg3.2.2sdk demo vs2015测试工程
- 我开通了公众号,看博客不方便的朋友建议加公众号
- QTextStream换行与追加写入
- ANALYZE TABLE Syntax
- 泛型初体验(-)
- Redis主从同步 和 持久化 Pipeline 原理
- 神经病院Objective-C Runtime出院第三天——如何正确使用Runtime
- Java内部类详解
- swift 闭包
- maven仓库、多环境
- iOS 如何实现Aspect Oriented Programming (上)