C ++ Qt Editor Question

I have a case where I need to manually close the persistent editor for QTableWidget .

By default, closing the editor does not save the changes to QTableWidgetItem (it just discards them).

I want to save these changes along with calling closePersistentEditor - how to do this?

I tried to fix cellChanged before calling closePersistentEditor - this did not help

+4
source share
1 answer

It 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); } 
+3
source

Source: https://habr.com/ru/post/1332100/


All Articles