QT文件操作
来源:互联网 发布:apache maven 编辑:程序博客网 时间:2024/06/07 08:11
#include "qfile.h"
#include "ui_qfile.h"
#include <QWidget>
#include <QFileDialog>
#include <QLabel>
#include <QDebug>
#include <QMessageBox>
#include <qtoolbutton.h>
#include <QWidget>
#include <QDataStream>
#include <QString>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QStream>
#define qDebug() << "[" <<_FILE_ <<":"<<_LINE_<<"]";//全局宏
QFile::File(QWidget *parent) :
QWidget(parent),
ui(new Ui::QFile)
{
ui->setupUi(this);
}
void readfile();
{
}
void writefile();
{
QDataStream stream(&file);
QString str;
int a;
stream >> str.toUtf8().data()>> a;
}
QFile::~QFile()
{
delete ui;
}
void QFile::on_Buttonread_clicked()
{
QFile file("../text.txt");
OString path =QFileDialog::getOpenFileName(this,
"open","../","TEX(*.txt");
bool isOK = file.open(QIODevice::ReadOnly); //判断只读
if(path.isEmpty()==false)
{
return 0;
}
else if(isOK==true) //打开文件成功
{
QByteArray array = file.readAll(); //把文件读到array Buff中
QFile file("path"); //建立一个文件file
ui->textEdit->setText(array);
//向文件力添加数据
QDataStream stream(&file);
stream << QString("主要看气质") <<250;
}
while(file.atEnd()==FALSE)
{
array+=file.readLine();
}
file.close();
}
阅读全文
0 0
- Qt文件流操作
- Qt文件流操作
- Qt写文件操作
- Qt文件流操作
- Qt之文件操作
- QT 文件读写操作
- Qt 文件读写操作
- QT文件操作
- Qt文件流操作
- QT文件操作
- qt文件操作(一)
- Qt文件操作
- Qt文件流操作
- QT 文件读写操作
- qt之文件操作
- Qt 文件操作
- QT 文件读写操作
- Qt文件操作总结
- HDU 6050 Funny Function
- 7.31网络讲座总结
- Find The Multiple POJ
- python学习-面向对象进阶之私有化(六)
- java中必背正则标记
- QT文件操作
- Java字符串工具简单操作类
- 实现高德地图定位
- MQactive
- 类与类的关系
- CSU 1562 Fun House(直线搜索)
- 洛谷P1006传纸条题解
- python学习-面向对象进阶之属性property(七)
- 变量