qt之QTextStream
来源:互联网 发布:淘宝网无线话筒 编辑:程序博客网 时间:2024/04/30 02:40
QTextStream 类 为读写文本数据提供了方便的接口
QFile data(“output.txt”);
If(data.open(QFIle::WriteOnly | QFile::Truncate))
{
QTextStream out(&data);
Out << “Result” << qSetFieldWidth(10) << left << 3.14 << 2.7;
// “Result:3.14 2.7”
}
QTextStream::QTextStream(QString * string, QIODevice::OpenMode openMode = QIODevice::ReadWrite)
构造一个QTextStream对象,用于操作string
QTextStream::QTextStream(QByteArray * array, QIODevice::OpenMode openMode = QIODevice::ReadWrite)
构造一个QTextStream对象,用于操作array对象。
bool QTextStream::atEnd() const
如果QTextStream对象没有更多的数据,则返回true
自动检测unicode编码
QTextCodec * QTextStream::codec() const
返回QTextStream的当前编码解码器
QIODevice * QTextStream::device() const
返回当前与QTextStream关联的设备,如果没有设备与之关联则返回NULL
FieldAlignment QTextStream::fieldAlignment() const
返回当前的调整格式
int QTextStream::fieldWidth() const
返回当前字段宽度。
void QTextStream::flush()
刷新缓冲区,而这些缓冲区中保存的是待写入设备的数据
bool QTextStream::generateByteOrderMark() const
如果当前设置的字节顺序标记为utf编码解码器,则返回true,否则返回false
qint64 QTextStream::pos() const
返回当前在流中的位置,出错返回-1.
StartFragment:0000000127 EndFragment:0000001410
QString QTextStream::read(qint64 maxlen)
在流中读取maxlen个字符返回。
QString QTextStream::readAll()
读取流中的所有数据
QString QTextStream::readLine(qint64 maxlen = 0)
在流中读取一行 并返回
bool QTextStream::readLineInto(QString * line, qint64 maxlen = 0)
在流中读取一行到line中
void QTextStream::resetStatus()
重置流的状态
bool QTextStream::seek(qint64 pos)
跳转到QTextStream流中pos位置。
void QTextStream::setCodec(QTextCodec * codec)
void QTextStream::setPadChar(QChar ch)
Sets the pad character to ch. The default value is the ASCII space character (' '), or QChar(0x20). This character is used to fill in the space in fields when generating text.
Example:
QString s;QTextStream out(&s);
out.setFieldWidth(10);
out.setFieldAlignment(QTextStream::AlignCenter);
out.setPadChar('-');
out << "Qt" << "rocks!";
The string s contains:
----Qt------rocks!--
QTextCodec支持的类型有
§ Big5
§ Big5-HKSCS
§ CP949
§ EUC-JP
§ EUC-KR
§ GB18030
§ HP-ROMAN8
§ IBM 850
§ IBM 866
§ IBM 874
§ ISO 2022-JP
§ ISO 8859-1 to 10
§ ISO 8859-13 to 16
§ Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml
§ KOI8-R
§ KOI8-U
§ Macintosh
§ Shift-JIS
§ TIS-620
§ TSCII
§ UTF-8
§ UTF-16
§ UTF-16BE
§ UTF-16LE
§ UTF-32
§ UTF-32BE
§ UTF-32LE
§ Windows-1250 to 1258
- qt之QTextStream
- QT输入输出(二) 之 QTextStream 测试
- Qt学习之路之QTextStream读写文本
- Qt模块化笔记之core——Input/Output文件操作-流QTextStream使用
- QTextStream
- QTextStream
- QT写文本文件(QTextStream 写文件)
- Qt: QTextStream流与QDataStream流
- QT写文本文件(QTextStream 写文件)
- Qt对文件的操作,QTextStream
- QT写文本文件(QTextStream 写文件)
- Qt使用Qtextstream进行换行操作
- QT ini配置文件的读写(使用QTextStream类)
- 【Qt学习笔记】——用QTextStream创建输入输出变量
- QTextStream类
- Qt编程11:QTextStream文件输入输出以及字符串操作的简单使用
- 4.关于QT中的QFile文件操作,QBuffer,Label上添加QPixmap,QByteArray和QString之间的区别,QTextStream和QDataStream的区别,QT内存映射(
- 4.关于QT中的QFile文件操作,QBuffer,Label上添加QPixmap,QByteArray和QString之间的区别,QTextStream和QDataStream的区别,QT内存映射(
- 操作系统实验之系统调用
- Dom4j 解析
- Android实现数据库中数据分页加载的功能
- C/C++中的static关键字的总结
- Java CMS Project 权限系统数据库设计
- qt之QTextStream
- 记录
- 日常杂记
- Ubuntu16.04下Qt交叉编译开发环境搭建
- 定位 position
- MySql5.7配置主从复制
- java DES加密解密实现
- 二两橙子的前端之路- -创建GitHub远程仓库
- java环境搭建基础知识