PDA

View Full Version : QTableView how to do something on start/end editing



nickla
15th March 2011, 08:47
Are there any signals (I cannot find anything in the docs) emitted when tha
user starts and ends the QTableView widget cell editation?

I want to execute some function from table model then user begins edit eny cell and execute another function when user ends editing. How can i do this?

MarekR22
15th March 2011, 09:21
If you have own data model then
On start editing QAbstractItemModel::data is called with role Qt::EditRole.
On finish editing QAbstractItemModel::setData is called. See subclasing section in QAbstractTableModel and QAbstractItemModel.

nickla
15th March 2011, 09:26
I put qDebug() but there is no output in console and my timer does not stop.


QVariant TxTableModel::data(const QModelIndex & index, int role) const
{
if (role == Qt::DisplayRole) {
return m_Data.getCell(index.row(), index.column());
}
if (role == Qt::SizeHintRole) {
return QSize(400, 50);
}
if (role == Qt::EditRole) {
//timer->stop();
qDebug() << "timer stop";
return m_Data.getCell(index.row(), index.column());
}
return QVariant();
}