I want to know when user has finished editing a QTableView item, so I checked all the available signals, but I only found ones that will emit before the edit.
So, what should I do now?
Running Qt 4.8.4
I want to know when user has finished editing a QTableView item, so I checked all the available signals, but I only found ones that will emit before the edit.
So, what should I do now?
Running Qt 4.8.4
Since your QTableView will have attached a model, connect to its signals,
eg void QStandardItemModel::itemChanged ( QStandardItem * item ) [signal]
or, more generally:
You can, also, connect to the selection model signals.
Usually, when you finish editing an item, focus changes to next, so selectionmodel will fire
currentChanged but this hasnt to be general.
True signal about finished editing you can find only in QAbstractItemDelegate
. It is closeEditor()
signal. All another signals from models will not work if user does not change anything in cell, but delegate is closed everytime when editing is finished. As doc said:
This signal is emitted when the user has finished editing an item using the specified editor.
The hint provides a way for the delegate to influence how the model and view behave after editing is completed. It indicates to these components what action should be performed next to provide a comfortable editing experience for the user. For example, if EditNextItem is specified, the view should use a delegate to open an editor on the next item in the model.
Usage:
connect(ui->tableView->itemDelegate(),SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),SLOT(someSlot()));
© 2022 - 2024 — McMap. All rights reserved.