1 支持方案json存储操作类 2 支持方案的json存储和解析、以及初始化 3 建立标准初始化json模版
This commit is contained in:
parent
4c89cb3e19
commit
cbe3be40b9
86
bin/0.json
Normal file
86
bin/0.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"A1": {
|
||||
"x": 2,
|
||||
"y": 410
|
||||
},
|
||||
"A2": {
|
||||
"x": 781,
|
||||
"y": 414
|
||||
},
|
||||
"C3": {
|
||||
"x": 263,
|
||||
"y": 411
|
||||
},
|
||||
"C4": {
|
||||
"x": 523,
|
||||
"y": 412
|
||||
},
|
||||
"Cz": {
|
||||
"x": 392,
|
||||
"y": 411
|
||||
},
|
||||
"F3": {
|
||||
"x": 293,
|
||||
"y": 253
|
||||
},
|
||||
"F4": {
|
||||
"x": 489,
|
||||
"y": 252
|
||||
},
|
||||
"F7": {
|
||||
"x": 197,
|
||||
"y": 224
|
||||
},
|
||||
"F8": {
|
||||
"x": 590,
|
||||
"y": 223
|
||||
},
|
||||
"Fp1": {
|
||||
"x": 306,
|
||||
"y": 150
|
||||
},
|
||||
"Fp2": {
|
||||
"x": 481,
|
||||
"y": 151
|
||||
},
|
||||
"Fz": {
|
||||
"x": 389,
|
||||
"y": 263
|
||||
},
|
||||
"O1": {
|
||||
"x": 307,
|
||||
"y": 679
|
||||
},
|
||||
"O2": {
|
||||
"x": 481,
|
||||
"y": 682
|
||||
},
|
||||
"P3": {
|
||||
"x": 293,
|
||||
"y": 582
|
||||
},
|
||||
"P4": {
|
||||
"x": 490,
|
||||
"y": 580
|
||||
},
|
||||
"Pz": {
|
||||
"x": 392,
|
||||
"y": 572
|
||||
},
|
||||
"T3": {
|
||||
"x": 133,
|
||||
"y": 410
|
||||
},
|
||||
"T4": {
|
||||
"x": 651,
|
||||
"y": 413
|
||||
},
|
||||
"T5": {
|
||||
"x": 195,
|
||||
"y": 608
|
||||
},
|
||||
"T6": {
|
||||
"x": 585,
|
||||
"y": 609
|
||||
}
|
||||
}
|
Binary file not shown.
@ -3,6 +3,8 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QButtonGroup>
|
||||
#include "operatorjson.h"
|
||||
#include <QApplication>
|
||||
LeadScheme::LeadScheme(QWidget * parent ):QWidget (parent)
|
||||
{
|
||||
init();
|
||||
@ -409,104 +411,19 @@ void LeadScheme::initLay()
|
||||
<<"O1"<<"O2";
|
||||
|
||||
QJsonObject json;
|
||||
|
||||
#if 0
|
||||
// "名称:Fp1\tx:306\ty:150"
|
||||
json.insert("Fp1",QJsonValue::fromVariant(QPoint(306,150)));
|
||||
//"名称:Fp2\tx:481\ty:151"
|
||||
json.insert("Fp2",QJsonValue::fromVariant(QPoint(481,151)));
|
||||
//"名称:F7\tx:197\ty:224"
|
||||
json.insert("F7",QJsonValue::fromVariant(QPoint(197,224)));
|
||||
// "名称:F3\tx:293\ty:253"
|
||||
json.insert("F3",QJsonValue::fromVariant(QPoint(293,253)));
|
||||
// "名称:Fz\tx:389\ty:263"
|
||||
json.insert("Fz",QJsonValue::fromVariant(QPoint(389,263)));
|
||||
//"名称:F4\tx:489\ty:252"
|
||||
json.insert("F4",QJsonValue::fromVariant(QPoint(489,252)));
|
||||
//"名称:F8\tx:590\ty:223"
|
||||
json.insert("F8",QJsonValue::fromVariant(QPoint(590,223)));
|
||||
// "名称:A1\tx:2\ty:410"
|
||||
json.insert("A1",QJsonValue::fromVariant(QPoint(2,410)));
|
||||
//"名称:T3\tx:133\ty:410"
|
||||
json.insert("T3",QJsonValue::fromVariant(QPoint(133,410)));
|
||||
//"名称:C3\tx:263\ty:411"
|
||||
json.insert("C3",QJsonValue::fromVariant(QPoint(263,411)));
|
||||
//"名称:Cz\tx:392\ty:411"
|
||||
json.insert("Cz",QJsonValue::fromVariant(QPoint(392,411)));
|
||||
//"名称:C4\tx:523\ty:412"
|
||||
json.insert("C4",QJsonValue::fromVariant(QPoint(523,412)));
|
||||
// "名称:T4\tx:651\ty:413"
|
||||
json.insert("T4",QJsonValue::fromVariant(QPoint(651,413)));
|
||||
//"名称:A2\tx:781\ty:414"
|
||||
json.insert("A2",QJsonValue::fromVariant(QPoint(781,414)));
|
||||
// "名称:T5\tx:195\ty:608"
|
||||
json.insert("T5",QJsonValue::fromVariant(QPoint(195,608)));
|
||||
//"名称:P3\tx:293\ty:582"
|
||||
json.insert("P3",QJsonValue::fromVariant(QPoint(293,582)));
|
||||
//"名称:Pz\tx:392\ty:572"
|
||||
json.insert("Pz",QJsonValue::fromVariant(QPoint(392,572)));
|
||||
//"名称:P4\tx:490\ty:580"
|
||||
json.insert("P4",QJsonValue::fromVariant(QPoint(490,580)));
|
||||
//"名称:T6\tx:585\ty:609"
|
||||
json.insert("T6",QJsonValue::fromVariant(QPoint(585,609)));
|
||||
//"名称:O1\tx:307\ty:679"
|
||||
json.insert("O1",QJsonValue::fromVariant(QPoint(307,679)));
|
||||
// "名称:O2\tx:481\ty:682"
|
||||
json.insert("O2",QJsonValue::fromVariant(QPoint(481,682)));
|
||||
#endif
|
||||
QList<QPoint> listPoints;
|
||||
listPoints.append(QPoint(306,150));
|
||||
|
||||
//"名称:Fp2\tx:481\ty:151"
|
||||
listPoints.append(QPoint(481,151));
|
||||
//"名称:F7\tx:197\ty:224"
|
||||
listPoints.append(QPoint(197,224));
|
||||
// "名称:F3\tx:293\ty:253"
|
||||
listPoints.append(QPoint(293,253));
|
||||
// "名称:Fz\tx:389\ty:263"
|
||||
listPoints.append(QPoint(389,263));
|
||||
//"名称:F4\tx:489\ty:252"
|
||||
listPoints.append(QPoint(489,252));
|
||||
//"名称:F8\tx:590\ty:223"
|
||||
listPoints.append(QPoint(590,223));
|
||||
// "名称:A1\tx:2\ty:410"
|
||||
listPoints.append(QPoint(2,410));
|
||||
//"名称:T3\tx:133\ty:410"
|
||||
listPoints.append(QPoint(133,410));
|
||||
//"名称:C3\tx:263\ty:411"
|
||||
listPoints.append(QPoint(263,411));
|
||||
//"名称:Cz\tx:392\ty:411"
|
||||
listPoints.append(QPoint(392,411));
|
||||
//"名称:C4\tx:523\ty:412"
|
||||
listPoints.append(QPoint(523,412));
|
||||
// "名称:T4\tx:651\ty:413"
|
||||
listPoints.append(QPoint(651,413));
|
||||
//"名称:A2\tx:781\ty:414"
|
||||
listPoints.append(QPoint(781,414));
|
||||
// "名称:T5\tx:195\ty:608"
|
||||
listPoints.append(QPoint(195,608));
|
||||
//"名称:P3\tx:293\ty:582"
|
||||
listPoints.append(QPoint(293,582));
|
||||
//"名称:Pz\tx:392\ty:572"
|
||||
listPoints.append(QPoint(392,572));
|
||||
//"名称:P4\tx:490\ty:580"
|
||||
listPoints.append(QPoint(490,580));
|
||||
//"名称:T6\tx:585\ty:609"
|
||||
listPoints.append(QPoint(585,609));
|
||||
//"名称:O1\tx:307\ty:679"
|
||||
listPoints.append(QPoint(307,679));
|
||||
// "名称:O2\tx:481\ty:682"
|
||||
listPoints.append(QPoint(481,682));
|
||||
OperatorJson Ojson;
|
||||
Ojson.readJson(QApplication::applicationDirPath()+"/0.json",json);
|
||||
|
||||
|
||||
qDebug()<<"hahaha"<<json<<endl;
|
||||
for(int i = 0 ; i< listNames.size();i++)
|
||||
{
|
||||
MoveButton * btn = new MoveButton(wClickedPints);
|
||||
btn->setParent(wClickedPints);
|
||||
int x =json[listNames.at(i)].toObject()["x"].toInt();
|
||||
int y = json[listNames.at(i)].toObject()["y"].toInt();
|
||||
|
||||
QPoint tempPoint = listPoints.at(i);//json.value(listNames.at(i)).toVariant().toPoint();
|
||||
|
||||
btn->setGeometry(tempPoint.x(), tempPoint.y(), radius, radius);
|
||||
btn->setGeometry(x,y, radius, radius);
|
||||
//x = x + radius;
|
||||
btn->setText(listNames.at(i));
|
||||
btn->setCanMove(true);
|
||||
@ -539,15 +456,25 @@ listPoints.append(QPoint(307,679));
|
||||
vlayAll->addLayout(hbtn);
|
||||
setLayout(vlayAll);
|
||||
}
|
||||
|
||||
#include "operatorjson.h"
|
||||
#include <QApplication>
|
||||
void LeadScheme::slotSave()
|
||||
{
|
||||
QJsonObject jsonSave;
|
||||
|
||||
for(int i = 0;i< m_listMoveBtns.size();i++ )
|
||||
{
|
||||
auto btn = m_listMoveBtns.at(i);
|
||||
QString text = btn->getText();
|
||||
int x = btn->x();
|
||||
int y = btn->y();
|
||||
QJsonObject perJson;
|
||||
perJson.insert("x",x);
|
||||
perJson.insert("y",y);
|
||||
jsonSave.insert(text,perJson);
|
||||
qDebug()<<QString("名称:%1\tx:%2\ty:%3").arg(text).arg(x).arg(y)<<endl;
|
||||
}
|
||||
}
|
||||
OperatorJson json;
|
||||
json.savaJson(jsonSave,QApplication::applicationDirPath()+"/0.json");
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "leadscheme.h"
|
||||
#include <QTextCodec>
|
||||
#include "MoveButton.h"
|
||||
#include "operatorjson.h"
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
@ -55,7 +56,6 @@ int main(int argc, char *argv[])
|
||||
globalFont.setFamily("黑体");
|
||||
QApplication::setFont(globalFont);
|
||||
|
||||
|
||||
QString qss1=R"(
|
||||
QLineEdit{
|
||||
border: 1px solid #ABCDA0; /* 边框宽度为1px,颜色为#A0A0A0 */
|
||||
|
64
xyylMCWEACSystem/operatorjson.cpp
Normal file
64
xyylMCWEACSystem/operatorjson.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "operatorjson.h"
|
||||
#include <QJsonDocument>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QByteArray>
|
||||
OperatorJson::OperatorJson(QObject * parent ):QObject (parent)
|
||||
{
|
||||
|
||||
}
|
||||
OperatorJson::~OperatorJson()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool OperatorJson::savaJson(QJsonObject obj, QString sPathFile)
|
||||
{
|
||||
{
|
||||
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray data = doc.toJson();
|
||||
QFile file(sPathFile);//json文件
|
||||
bool ok = file.open(QIODevice::WriteOnly);
|
||||
if (ok)
|
||||
{
|
||||
file.write(data);
|
||||
file.close();
|
||||
}
|
||||
return ok;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool OperatorJson::readJson(QString sPathFile, QJsonObject & json)
|
||||
{
|
||||
//读入所有内容
|
||||
QFile file(sPathFile);
|
||||
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray data = file.readAll();
|
||||
file.close();
|
||||
//解析
|
||||
QJsonParseError jsonError;
|
||||
QJsonArray jsonAarray;
|
||||
|
||||
QByteArray array(data.toStdString().c_str());
|
||||
QJsonDocument document = QJsonDocument::fromJson(array, &jsonError);
|
||||
|
||||
if (jsonError.error == QJsonParseError::NoError)
|
||||
{
|
||||
//logInfo() << array << endl;
|
||||
//jsonAarray = document.array();
|
||||
json = document.object();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
15
xyylMCWEACSystem/operatorjson.h
Normal file
15
xyylMCWEACSystem/operatorjson.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef OPERATORJSON_H
|
||||
#define OPERATORJSON_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
class OperatorJson:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OperatorJson(QObject * parent = NULL );
|
||||
~OperatorJson();
|
||||
bool savaJson(QJsonObject obj, QString sPathFile);
|
||||
bool readJson(QString sPathFile, QJsonObject & json);
|
||||
};
|
||||
#endif // OPERATORJSON_H
|
@ -46,6 +46,7 @@ SOURCES += \
|
||||
medicalrecordmanager.cpp \
|
||||
medicalrecordwidget.cpp \
|
||||
navlistwidget.cpp \
|
||||
operatorjson.cpp \
|
||||
parametersettingswidget.cpp \
|
||||
regwidget.cpp \
|
||||
systemsettingwidget.cpp \
|
||||
@ -73,6 +74,7 @@ HEADERS += \
|
||||
medicalrecordwidget.h \
|
||||
mrmanagement.h \
|
||||
navlistwidget.h \
|
||||
operatorjson.h \
|
||||
parametersettingswidget.h \
|
||||
regwidget.h \
|
||||
systemsettingwidget.h \
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.9.1, 2024-11-22T17:27:54. -->
|
||||
<!-- Written by QtCreator 4.9.1, 2024-11-29T16:52:00. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
Loading…
x
Reference in New Issue
Block a user