Qt World Summit: Register Today!

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.

  • @Fuel-0

    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...

  • User editing a cell is not a task the view does, it's something for the delegate:

    class EditFinishDelegate : public QStyledItemDelegate{
        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 {

    You can use it like:

    EditFinishDelegate* delegate = new EditFinishDelegate(this);

Log in to reply