qt - QTableView: dataChanged event clears cell being edited -
working qtableview
, qabstracttablemodel
- when model emits datachanged
event cell being edited, string user has typed in cell (but not pressed enter 'commit' edit) erased.
example: click cell, type '123', cell still in edit mode waiting more text, datachanged
emitted , '123' erased, leaving empty cell in edit mode.
does know how stop behaviour, or how model can detect when cell being edited prevent datachanged
events being raised cell?
check model class, should override setdata method in model. if every thing correct update model after editing data... please let me know if have implementation
bool mymodel::setdata(const qmodelindex &index, const qvariant &value, int role) { if (index.isvalid() && role == qt::editrole) { int row = index.row(); int col = index.column(); //// change data emit(datachanged(index, index)); return true; } return false; }
Comments
Post a Comment