Hello,i am studying the address book example on Qt Assistant and on the address book example i have a come across usages of Qvariant which i don't understand.
Here is the code:
{
if (!index.isValid())
return QVariant();
//what does the use of Qvariant here mean - 1
if (index.row() >= listOfPairs.size() || index.row() < 0)
return QVariant();
//what does the use of Qvariant here mean - 2
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();
//what does the use of Qvariant here mean - 3 }
QVariant TableModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();//what does the use of Qvariant here mean - 1
if (index.row() >= listOfPairs.size() || index.row() < 0)
return QVariant();//what does the use of Qvariant here mean - 2
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();//what does the use of Qvariant here mean - 3
}
To copy to clipboard, switch view to plain text mode
I have commented on the code next to Qvariant usages.Someone help me understand what it means.
Bookmarks