PDA

View Full Version : problem with rowCount method



sergio486
18th December 2010, 01:06
Hi everybody,

I defined my own TableModel using the QAbstractTableModel class...all run perfectly just i couldn't use the rowCount method in my program :

"no Matching function for call to TableModel::rowCount const"
"condidates are virtual int TableModel::rowCount const"

i'm sure that i have defined correctly the virtual method but i don't know what happened ? i have also changed the example of adresse book:

QVariant TableModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();

if (index.row() >= /*listOfPairs.size()*/ rowCount() || index.row() < 0)
return QVariant();

if (role == Qt::DisplayRole) {
QPair<QString, QString> pair = listOfPairs.at(index.row());

if (index.column() == 0)
return pair.first;
else if (index.column() == 1)
return pair.second;
}
return QVariant();
}
same fact !!
any idea ??

Everall
18th December 2010, 01:51
How does your method look like exactly?
What is the return type?

Everall

wysota
18th December 2010, 09:37
Make sure that the declaration of the method in your subclass allows a default argument for the parent model index.