I am trying to prevent user from entering the same data into my model, which is subclassed from QAbstractTableModel.
bool MyModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
bool result = false;
...
// Test if my model already has the same data
result = findItem( value.toString() ) != -1;
...
if ( result )
emit( dataChanged( index, index );
else
emit ( dataInvalid( index ) );
return result;
}
Now I should catch the signal and turn my table view (which type is QTableView) back to editing state:
void MyWindow::dataInvalid( const QModelIndex &index )
{
myTableView->edit( index );
}
But when I run my application I got message in the console and QTableView does not turn to editing state:
edit: edit failed
What am I doing wrong? Thank you very much in advance.