头文件
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QJsonDocument>
#include <QJsonObject>
#include <QVariantMap>
#include <QFile>
#include <QDebug>
#include <QMessageBox>
//通道信息
typedef struct _STChannelInfo
{
QString uuid; //标识
QString strName; //名称
QList<QStringList> paraValue;//参数值
void operator=(const _STChannelInfo &other )
{
this->uuid = other.uuid;
this->strName = other.strName;
this->paraValue = other.paraValue;
}
}STChannelInfo;
//板卡信息
typedef struct _STCardInfo
{
QString uuid; //标识
QString strName; //名称
QList<STChannelInfo> channelInfo;
void operator=(const _STCardInfo &other )
{
this->uuid = other.uuid;
this->strName = other.strName;
this->channelInfo = other.channelInfo;
}
}STCardInfo;
//设备信息
typedef struct _STDeviceInfo
{
QString uuid; //标识
QString strName; //名称
QList<STCardInfo> cardInfo;//板卡信息
void operator=(const _STDeviceInfo &other )
{
this->uuid = other.uuid;
this->strName = other.strName;
this->cardInfo = other.cardInfo;
}
}STDeviceInfo;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QList<STDeviceInfo> m_deviceInfo;
private:
Ui::MainWindow *ui;
void iniVar();//初始化变量
void writeJsonFile();//写json文件
void readJsonFile();//读json文件
};
#endif // MAINWINDOW_H
CPP文件
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//--1 初始化变量
iniVar();
//--2 写json文件
writeJsonFile();
//--3 读json文件
readJsonFile();
}
MainWindow::~MainWindow()
{
delete ui;
}
// 初始化变量
void MainWindow::iniVar(