PDA

View Full Version : Model's flags method



Higgs
11th September 2014, 21:55
Hi. I'm reading official Qt documentation and I can't understant piece of code:


//! [quoting mymodel_f]
Qt::ItemFlags MyModel::flags(const QModelIndex &index) const
{
return Qt::ItemIsEditable | QAbstractTableModel::flags(index);
}
//! [quoting mymodel_f]



Qt::ItemIsEditable | QAbstractTableModel::flags(index);

Why we can't just return Qt::ItemIsEditable?

Infinity
11th September 2014, 22:49
The default implementation returns "Qt::ItemIsSelectable|Qt::ItemIsEnabled" for valid indexes (see qabstractitemmodel.cpp).
If you want to return these default flags in your custom implementation you might want to call the default implementation as shown in your piece of code. If not simply return the flags you need.