Unsolved Searching for a QtableView editFinished like Signal
-
I do have a sheet containing QTableView that is representing the content of a QAbstractTableModel.
I would like to provide a Save Button on the sheet that should be getting activated when the edited content of the QTableView has changed rather then when the data provided by the QAbstractTableModel has changed as my Model is updating some information from time to time that don't need to be changed (Current Time f.e.). So connecting to the model dataChanged signal is actually not an option for me - I would rather like to connect to a signal from the QtableView like editFinished... problem is that this signal does not exist.Maybe someone knows some alternative way to archive this.
-
It could be an Option to define an own Signal and everytime you doing something you can emit it. You can try to combine dataChanged and your other Functions.
-
It could be an Option to define an own Signal and everytime you doing something you can emit it.
I suspect @Laurent-Schall is aware of this. The problem is: how do you (easily) recognise "everytime you doing something [to it]"? That's why he is asking if
QTableView
has any such signal to help him achieve this... -
@Laurent-Schall
There are some other people who have asked your question :)
I don't see a definitive resolution, but you might like to have a read for ideas through: -
User editing a cell is not a task the view does, it's something for the delegate:
class EditFinishDelegate : public QStyledItemDelegate{ Q_OBJECT Q_DISABLE_COPY(EditFinishDelegate) public: explicit EditFinishDelegate(QObject *parent =Q_NULLPTR) : QStyledItemDelegate(parent){} Q_SIGNAL void editFinished(const QModelIndex &index); void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE { QStyledItemDelegate::setModelData(editor,model,index); editFinished(index); } };
You can use it like:
EditFinishDelegate* delegate = new EditFinishDelegate(this); connect(delegate,&EditFinishDelegate::editFinished,saveButton,std::bind(&QPushButton::setEnabled,saveButton,true)); tableView->setItemDelegate(delegate);