Pergunta
I have the case when I have to manually close the persistent editor for the QTableWidget
.
By default, closing the editor this doesn't result in saving the changes to the QTableWidgetItem
(it simply discards them).
I wish to save these changes along with the closePersistentEditor
call - how should it be done?
I tried emitting cellChanged
before the closePersistentEditor
call - it didn't help
Solução
Looks like you can write something like this
void MyTableWidget::commitAndClosePersistentEditor(const QTableWidgetItem* item)
{
if (!item)
return;
QModelIndex index = indexFromItem(item);
QWidget* editor = indexWidget(index);
commitData(editor);
closePresistentEditor(item);
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow