What's the "editing finished" signal of a QTableView item?
Asked Answered
T

2

6

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

Terrigenous answered 29/4, 2013 at 6:57 Comment(0)
C
9

Since your QTableView will have attached a model, connect to its signals,

eg void QStandardItemModel::itemChanged ( QStandardItem * item ) [signal]

or, more generally:

void QAbstractItemModel::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight )

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.

Corene answered 29/4, 2013 at 9:32 Comment(0)
C
9

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()));
Constructionist answered 12/10, 2015 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.