QTはある経路に情報を保存する(2)

2146 ワード

main.cpp
#include "mainwindow.h"
#include 

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}


file.cpp
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

//upload
void 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()<show_file_name->setText(m_strFileName);

}


//save file and message
void 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()<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<