Qt写入txt文件
2015-07-06 09:10
405 查看
void MainWindow::on_pushButton_clicked()
{
QDateTime da_time;
QString time_str=da_time.currentDateTime().toString("yyyy-MM-dd HH-mm-ss");
QString runPath = QCoreApplication::applicationFilePath();
ui->label->setText(runPath);
QDir *TEST = new QDir;
bool exist = TEST->exists("TEST");
if(!exist)
bool ok = TEST->mkdir("TEST");
QString fileName = "TEST/1.txt";
QString str="0000000nnnnnnnnnnnnnnnn";
QFile file(fileName);
if(!file.open(QIODevice::WriteOnly | QIODevice::Text|QIODevice::Append))
{
QMessageBox::warning(this,"sdf","can't open",QMessageBox::Yes);
}
QTextStream in(&file);
in<<time_str+":"+str<<"\n";
file.close();
}
相关文章推荐
- QT学习 第一章:基本对话框
- 使用Shiboken为C++和Qt库创建Python绑定
- Qt定时器和随机数详解
- Qt实现图片移动实例(图文教程)
- Qt for Android开发实例教程
- QModelIndex/Role/Model介紹<二>
- 基于PyQt5的快速开发框架QFramer
- ok6410开发板移植DirectFB手记
- 【笔记】给Qt内嵌一个Chrome吧
- 【算法】最短路径之A*搜索
- qt入门必备
- 在 Qt4 中使用 C++11
- Hello Word ~ v0.2.2 背单词软件发布 -- By WHYPRO
- ubuntu下opencv和qt的安装配置
- linux下opengl的安装(with qt)
- qt 学习小节
- QT的命名风格
- QT 中的sleep
- QT 串口的监控
- 在VS2010下配置QT和ITK+VTK