Question

I have a QTreeView with data that changes over time, with a dataChanged signal being emitted in the QAbstractItemModel every second. The items in the QTreeView can be edited as well, but when a editor is opened for a certain item the editor string is updated while I edit is, which is very annoying. Any way to prevent an editor to be updated with the new values?

Was it helpful?

Solution

Do you use your own model with QTreeView? In this case you overwrite it and not return any data for Qt::EditRole. If it is not convenient for you (you want to have the current data in the field when you begin to edit it), then you could create your own QItemDelegate/QStyledItemDelegate and implement some custom logic there: make it so the widget is not updated with new value, when it has focus, for example.

Althought I might be missing something, and there is an easier way to do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top