문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top