QT将信息保存到某个路径下(2)
来源:互联网 发布:淘宝买csgo怎么下载 编辑:程序博客网 时间:2024/06/05 20:52
main.cpp
#include "mainwindow.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}
file.cpp
#include <QFileDialog>#include <QMessageBox>#include <QDebug>#include <QDir>#include <QFile>#include <QTextStream>#include <QIODevice>#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this);}MainWindow::~MainWindow(){ delete ui;}//uploadvoid MainWindow::on_upload_clicked(){ QString path = QFileDialog::getOpenFileName(this, tr("Open Document"), QDir::currentPath(), tr("Document Files(*.*);All files(*.*)")); if(path.length() == 0) { //友好提示信息 QMessageBox::information(NULL, tr("path"), tr("You didn't select ant files.")); } else { QMessageBox::information(NULL, tr("path"), tr("You selected") + path); } //QString showFileName = ui->show_file_name->text(); //qDebug()<<"file_name = "<< showFileName; int position = path.lastIndexOf("/") + 1; //qDebug() << "pos=" << position; m_strFileName = path.mid(position); //qDebug()<< "filename = " << m_strFileName; ui->show_file_name->setText(m_strFileName);}//save file and messagevoid MainWindow::on_save_clicked(){ //TDD QString strName = ui->user_name->text(); QString strPass = ui->passwd->text(); //QString path = QFileDialog::getOpenFileName(this, tr("Open Document"), QDir::currentPath(), tr("Document Files(*.*);All files(*.*)")); //qDebug()<<"user_name = "<< strName; //qDebug()<<"user_pass = "<< strPass; QDir *TEST = new QDir; //判断目录是否存在不存在则创建 bool exist = TEST->exists("/home/桌面/qt_train/test_02/TEST"); if(!exist) bool ok = TEST->mkdir("/home/桌面/qt_train/test_02/TEST"); QString fileName = "/home/qt_train/test_02/TEST/dockfile.txt"; 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<<"user_name:" + strName<<"\n"; in<<"user_password:" + strPass<<"\n"; in<<"user_filename:" + m_strFileName<<"\n"; QFile::copy(const QString & m_strFileName, const QString & m_strFileName_new); file.close();}
阅读全文
0 0
- QT将信息保存到某个路径下(2)
- QT将信息保存到某个路径下(1)
- QT将信息保存到某个路径下(3)
- python 遍历某个路径下的所有图片并将图片路径保存到数组
- 笔记94--将崩溃信息保存到本地(下)
- Qt-将QDebug信息保存到文件中
- Qt将文件保存到指定目录下(另存为的功能)
- Qt将文件保存到指定目录下(另存为的功能)
- Qt将文件保存到指定目录下(另存为的功能)
- [置顶] Qt将文件保存到指定目录下(另存为的功能) .
- asp将base64的图片信息,转为图片显示,并保存到指定路径
- Javaweb中的文件批量上传,并将文件路径等信息保存到数据库中
- 笔记92--将崩溃信息保存到本地(上)
- Android将bitmap保存到自定义路径
- Enterprise Library 2.0 技巧(2):如何将配置信息保存到数据库中
- 遍历当前目录下所有的.h文件,并将其路径保存到文件中
- 如何将DOS下执行命令的结果信息保存到一个文件
- 将选中的物体进行修改保存到XML或者保存到Assets目录下的某个预制以及自定义快捷键=_=
- CentOS7.3中Tomcat8启动出错问题
- EasyStream系列3之rtsp转rtsp
- C 和 C++的对比
- speex中的AEC框架介绍(in C)
- android开发 NDK 编译和使用静态库、动态库
- QT将信息保存到某个路径下(2)
- Python3之hashlib模块
- Maven工程运行报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- WPF Virtualizing Panel
- basic
- 创意族贺小米七周年庆专题:国际“米淘”热潮
- Picture
- python读写excel文件
- php数组根据某一个键值,把相同键值的合并生成一个新的二维数组