I have subclassed QAbstractTableModel and in data() function I am displaying an image in last column of each row and a tooltip on mouse hover.
QVariant MyTableModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::DisplayRole)
{
switch (index.column())
{
// few cases
default:
return QVariant();
}
}
else if (role == Qt::CheckStateRole && index.column() == 0)
{
int state= tableData.at(index.row()).state;
if (state)
return Qt::Checked;
else
return Qt::Unchecked;
}
else if (role == Qt::DecorationRole && index.column() == 7 && index.row() > 1)
{
QPixmap pixMap(fileName);
return pixMap;
}
else if (role == Qt::ToolTipRole && index.column() == 7 && index.row() > 1)
{
return QString("Delete");
}
else
return QVariant();
}
Tooltip text is displayed fine on each row but when I move cursor from last column of a row to another last column just below it(or any row below it) tooltip remains on the upper row.
This issue does not persist if cursor is moved to any other cell before moving to last column of another row. Thanks for help.