QT向txt写入数据
一、QT向txt写入数据
windows下txt文档的换行符是由两个字符”\r\n”构成的,,而linux下的文档的换行符号是’\n’
所以改为myfile.write(“mimixiaoqiche\r\n”);

二、QT如何打开txt并把内容显示在textEdit中(有中文)
QFile file(“xxxx.txt”); if(file.open(QIODevice::ReadOnly)) { QTextStream read(&file); while(!read.atEnd() ) { tetedit->Append(read.readLine()); } } dbInfo.close();
三、qt的qfile中怎样添加内容到txt文档中?
1..o::Append);加这2.一般在中间插入都是确定知道文件的结构.seek(pos);file.write(sth);通过相应的位移实现