Home > Mobile >  QTableView add custom in line
QTableView add custom in line

Time:10-12

I use the method of setting DataModel and ItemDelegate in QTableView QCheckBox and realize on line QTableView to add QComboBox control function, control now have been able to add, but every time after a row has been added, has on line control of operation will be reset, ask how to solve?
Add new lines of code:
 
M_pModel2 - & gt; AddFormula (1, 1, 0, false);
for (int i=0; i {
UI. LvContainer - & gt; OpenPersistentEditor (m_pModel2 - & gt; The index (I, 0));
UI. LvContainer - & gt; OpenPersistentEditor (m_pModel2 - & gt; The index (I, 1));
UI. LvContainer - & gt; OpenPersistentEditor (m_pModel2 - & gt; The index (I, 2));
UI. LvContainer - & gt; OpenPersistentEditor (m_pModel2 - & gt; The index (I, 3));
}

AddFormula function implementation:
 
Void FormulaListModel: : AddFormula (int op1, int op2, int op, bool isEnable)
{
BeginResetModel ();
PFORMULA pf=new FORMULA;
Pf - & gt; Op=op;
Pf - & gt; Op1=op1;
Pf - & gt; Op2=op2;
Pf - & gt; IsEnable=isEnable;
M_lsFormula & lt; EndResetModel ();
}

Caveat: I want to achieve is to realize a formula editor in QTableView function, each time adding a new formula, which produce a new line, including three QComboBox QCheckBox and controls,

CodePudding user response:

Control the state of preservation in the model? You keep the state into the model, and then in itemdelegate by reading the model of state data show that the control again, ok
  •  Tags:  
  • Qt
  • Related