qt5文件读写的简单用法
来源:互联网 发布:js实现点击重置按钮 编辑:程序博客网 时间:2024/06/08 04:39
版本: 5.6.2 qt 和 4.0.3 qt creator
首先, UI是这样的:
需要注意的一点就是, “注册“ 这个按钮转为了click()槽。
在源文件中的file.cpp中, 因为上面槽的设置, 自动生成了button的函数框架, 主要的实现都在这里
void file::on_OkButton_clicked(){ QString m_number = ui->number->text(); QString m_name = ui->name->text(); QFile read_file("./file.txt"); read_file.open(QIODevice::ReadOnly); QTextStream in(&read_file); QString line = in.readAll(); read_file.close(); QFile write_file("./file.txt"); write_file.open(QIODevice::WriteOnly); QTextStream out(&write_file); out << line << "\r\n" << m_number << " " << m_name << endl; write_file.close();}
这样就完成了, 实现的功能是, 往file.txt写入信息, 每次注册都会往txt里面添加新的信息。
阅读全文
0 0
- qt5文件读写的简单用法
- Qt5 文件读写
- 简单的文件读写
- 简单的读写文件
- 简单的读写文件
- 文件的简单读写
- 简单的文件读写
- 文件的简单读写
- 简单的文件读写
- Qt5.8 读写txt文件
- Qt5菜鸟入门(3):文件的读写和输出
- Ruby简单的读写文件
- Ruby简单的读写文件
- 最简单的读写文件
- Perl简单的文件读写
- NSFileHandle简单的读写文件
- ini文件的简单读写
- 简单实现文件的读写
- 【Lua】面向对象
- 值得推荐的C/C++框架和库
- vue mint-ui tabbar变组件使用
- SpringMVC中的@InitBinder标签
- a label can only be part of a statement and a declaration is not a statement
- qt5文件读写的简单用法
- Android高效加载大图、多图解决方案,有效避免程序OOM
- Spring之IOC、AOP的理解
- JQ实现轮播
- docker centos redis 基础常用命令
- 【PAT 1004 Acute Stroke (30)】& dfs
- 【PAT】【Advanced Level】1095. Cars on Campus (30)
- BeautifulSoup库中find_all()方法
- 2017最新java学习大全