1.运行截图
![](https://img-blog.csdnimg.cn/20190829121903365.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d6ejk1MzIwMDQ2Mw==,size_16,color_FFFFFF,t_70)
2.源码
//.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QList>
namespace Ui {
class Widget;
}
struct EnjoyFruits
{
QString FruitName;
QString FruitColor;
};
struct Student
{
QString name;
int age;
QString city;
QList<EnjoyFruits> fruits;
};
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
public slots:
void onToJsonBtnClicked();
void onToTextBtnClicked();
public:
void writeEdit(QString name,QString value);
private:
Ui::Widget *ui;
Student student;
};
#endif // WIDGET_H
// .cpp
#include "