jsontoexcel/mainwindow.cpp

54 lines
1.0 KiB
C++

#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
_jsontoexcel = new JsonToExcel();
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(selectFile()));
connect(ui->jsonPars, SIGNAL(clicked()), this, SLOT(on_jsonPars_clicked()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::selectFile()
{
QString path = QFileDialog::getOpenFileName(this, tr("select excel template path"));
if (path.isEmpty())
return;
ui->lineEdit->setText(path);
//readFile();
}
QString MainWindow::readFile()
{
QString val;
QFile file;
qDebug() << ui->lineEdit->text();
file.setFileName(ui->lineEdit->text());
file.open(QIODevice::ReadOnly | QIODevice::Text);
val = file.readAll();
//qDebug() << val;
file.close();
//on_jsonPars_clicked(&val);
return val;
}
void MainWindow::on_jsonPars_clicked()
{
_jsontoexcel->jsonParsToExcel(readFile());
}