is the code is a bug?
-
I made a class named STableItem which inherited from the QTableWidgetItem.
the STableItem class set the checked mode .
and after I set the STableItem class into the QTableWidget,I put the instance of the STableItem into an qlist,which like this:class STableItem :public QTableWidgetItem{
QJsonObject var_data;
void doAction();
}
STableItem * titem = new STableItem ();
QList<STableItem *> mlist;
QTableWidget table;
table.setItem(0,0,titem);
mlist.push_back(titem);after that I changed the text by using
mlist.at(0).doAction();
but the var_data of the titem occured the errors.so what should i do to get the real item and call the method of the instance? -
I made a class named STableItem which inherited from the QTableWidgetItem.
the STableItem class set the checked mode .
and after I set the STableItem class into the QTableWidget,I put the instance of the STableItem into an qlist,which like this:class STableItem :public QTableWidgetItem{
QJsonObject var_data;
void doAction();
}
STableItem * titem = new STableItem ();
QList<STableItem *> mlist;
QTableWidget table;
table.setItem(0,0,titem);
mlist.push_back(titem);after that I changed the text by using
mlist.at(0).doAction();
but the var_data of the titem occured the errors.so what should i do to get the real item and call the method of the instance?@nicker-player Please format your code properly!
Please post the error you get!Where is this:
QTableWidget table;
If it is in a method/function - what do you think what its lifespan is?