QSerializer icon indicating copy to clipboard operation
QSerializer copied to clipboard

In this case, it is not possible to get.

Open HaonPAPA opened this issue 3 years ago • 2 comments

hello thanks a lot for help In my case, I tested it, and it is confirmed that the file is written normally.

But in the process of getting the value with Get, I got an abnormal result.

class cModelCommon : public cSerializer
{
public:
	        Q_GADGET
		QS_SERIALIZABLE

		QS_FIELD(QString, strMethodName)				//	메소드 이름 
		QS_FIELD(QString, strMemo)						//	메모
		QS_FIELD(int, nTime)							//	횟수
		QS_FIELD(int, nUnit)							//	단위
		QS_FIELD(QDateTime, CreationTime)				//	생성 시간
		QS_COLLECTION(QVector, int, vWaveLength)		//	파장
		QS_COLLECTION(QVector, int, vCelltype)			//	셀 타입 Ex) B,1,2..., S(Single)
};

class cModelQuantitation : public cModelCommon
{
	Q_GADGET
		QS_SERIALIZABLE
		QS_OBJECT(cModelQuantitation_MeasureData,	cMeasureData)	 //	측정결과
		QS_OBJECT(cModelStandardCurve,				cStandardCurve)	 //	리포트옵션
		QS_OBJECT(cReportOption,					cReportopt)		 //	리포트옵션
};

class cModelStandardCurve_MeasureData : public cSerializer
{
	Q_GADGET
		QS_SERIALIZABLE

private:
		QS_FIELD(bool, IsChecked)								//	체크박스 상태
		QS_COLLECTION(QVector, qreal, vABS)						//	흡광도
		QS_COLLECTION(QVector, qreal, vConc)					//	농도
		QS_COLLECTION(QVector, qreal, vDispExp)					//	차트 axis?
		QS_COLLECTION(QVector, qreal, vCalcExp)					//	수식
};

class cModelStandardCurve : public cModelCommon
{
	Q_GADGET
		QS_SERIALIZABLE
		QS_FIELD(int, nFactor)										//	희석배수
		QS_FIELD(int, nSTCType)										//	STC 타입 
		QS_FIELD(int, nRSQ)											//	RSQ

		QS_OBJECT(cModelStandardCurve_MeasureData, cMeasureData)	//	측정결과
		QS_OBJECT(cReportOption, cReportopt)						//	리포트옵션
};
class cReportOption : public cSerializer
{
	Q_GADGET
		QS_SERIALIZABLE

		QS_FIELD(bool, bShowTitle)						//	측정 타이틀
		QS_FIELD(bool, bShowDeviceInfo)					//	장비 정보
		QS_FIELD(bool, bShowInfo)						//	상세 정보
		QS_FIELD(bool, bShowData)						//	측정 데이터 
		QS_FIELD(bool, bShowChart)						//	차트 정보
};

This is the case with the class relationship diagram, what should I do to properly handle this case?

Fields of cModelCommon class are imported normally. However, the class object of cModelQuantitation gets the initial value.

HaonPAPA avatar Jan 03 '22 02:01 HaonPAPA

In this case, cModelQuantitation_MeasureData must be inherited from QSerializer. Also, i don't tested non direct inherit with many base-classes. Maybe, Q_PROPERTY work not correctly in this case.

smurfomen avatar Jan 03 '22 08:01 smurfomen

이 경우 cModelQuantitation_MeasureData는 QSerializer에서 상속되어야 합니다. 또한 많은 기본 클래스로 비 직접 상속을 테스트하지 않았습니다. 이 경우 Q_PROPERTY가 제대로 작동하지 않을 수 있습니다.

class cModelQuantitation_MeasureData : public cSerializer
{
	Q_GADGET
		QS_SERIALIZABLE

		QS_FIELD(bool, IsChecked)								//	체크박스 상태
		QS_COLLECTION(QVector, qreal, vConc)					//	농도
		QS_COLLECTION(QVector, qreal, vTRA)						//	투과율
		QS_COLLECTION(QVector, qreal, vABS)						//	흡광도
		QS_COLLECTION(QVector, QString, vCellNumber)			//	셀번호
		QS_FIELD(QString, strSampleName)						//	샘플명
		QS_FIELD(double, strTemperature)						//	온도
};

cModelQuantitation_MeasureData is also used by inheriting cSerializer. Any solution?

==========================================================

Fields in cModelStandardCurve get values normally. However, the contents of QS_COLLECTION and QS_OBJECT cannot be imported.

==========================================================

One thing I found is that the contents of metaObject()->property(i).name() come in as class variable names, not class names. If it comes in as a class name, it seems to be normal behavior.

==========================================================

if (name == "cSTC_MeasureData")
			{
				auto f = doc.firstChildElement("cModelStandardCurve_MeasureData");
				if(!f.isNull())
					metaObject()->property(i).writeOnGadget(this, QVariant::fromValue<QDomNode>(f));
			}
			else if (name == "cSTC_Reportopt")
			{
				auto f = doc.firstChildElement("cReportOption");
				if (!f.isNull())
					metaObject()->property(i).writeOnGadget(this, QVariant::fromValue<QDomNode>(f));
			}

By modifying the else part of the fromXml function like this, it works normally. Is there any other way besides what I did? The method I'm doing now is a passive method.

HaonPAPA avatar Jan 03 '22 08:01 HaonPAPA