How to copy a form class
-
wCellTypeInfo* temp = new wCellTypeInfo(m_pModelInfo, m_pParentWidget); wSetupBaseBckg dlg(temp, m_pParentWidget); { m_pCellTypeInfo = temp; if (dlg.DlgResult() == CollectEnums::MeasureMode_Settings::Apply) { /*wPhotoMetric_Settings* w = qobject_cast<wPhotoMetric_Settings*>(dlg.GetWidget()); if (w->IsChanged()) UpdateMesureInfo(); this->m_pChart->EnableMarkers(m_pPhometricInfo->bPVDisplay);*/ }
When exiting the function, the wCellTypeInfo* temp variable is destroyed.
Although it was copied with the assignment operator before being destroyed, the copied class is also destroyed because temp itself is destroyed. Is there any way to copy the form class itself?I made a deepcopy, but it doesn't copy the information in the UI
void wCellTypeInfo::DeepCopy(const wCellTypeInfo* copy) { ui = copy->ui; m_nChkCnt = copy->m_nChkCnt; m_pModelInfo = copy->m_pModelInfo; m_nSeletedCell = copy->m_nSeletedCell; m_pBtnGroup = copy->m_pBtnGroup; //m_pParentWidget = copy.m_pParentWidget; }
-
@IknowQT said in How to copy a form class:
Although it was copied with the assignment operator before being destroyed, the copied class is also destroyed because temp itself is destroyed. Is there any way to copy the form class itself?
Maybe because wSetupBaseBckg deletes it in it's dtor.
Simply create a new instance of temp if you need another one. -
@IknowQT said in How to copy a form class:
When exiting the function, the wCellTypeInfo* temp variable is destroyed
Where is it destroyed?
I don't see any delete in the code you posted.You can't copy QObject based classes in Qt. The only thing you can copy is the pointer, but then it is NOT a deep copy...