Hello,
I have created QAbstractListModel in the data function I check for the DecorationRole and when that is passed to the function I check for the right column and return a pixmap but I can't get it to work
ResultModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid())
if(Qt::DisplayRole != role)
ResultItem item = fItems.at(index.row());
if(Qt::DisplayRole == role)
{
if(kColumnFileName == index.column())
return item.file().fileName();
if(kColumnExpectedChecksum == index.column())
return item.expectedChecksum();
if(kColumnCalculatedChecksum == index.column())
return item.calculatedChecksum();
}
// does not work
//
else if(Qt::DecorationRole == role)
{
TRACE("Decoration column: %d\n", index.column());
if(kColumnStatus == index.column())
{
int status = item.status();
TRACE("Choosing error: %d\n", status);
if(ResultItem::kStatusOk == status)
}
}
}
QVariant
ResultModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid())
return QVariant();
if(Qt::DisplayRole != role)
return QVariant();
ResultItem item = fItems.at(index.row());
if(Qt::DisplayRole == role)
{
if(kColumnFileName == index.column())
return item.file().fileName();
if(kColumnExpectedChecksum == index.column())
return item.expectedChecksum();
if(kColumnCalculatedChecksum == index.column())
return item.calculatedChecksum();
}
// does not work
//
else if(Qt::DecorationRole == role)
{
TRACE("Decoration column: %d\n", index.column());
if(kColumnStatus == index.column())
{
int status = item.status();
TRACE("Choosing error: %d\n", status);
if(ResultItem::kStatusOk == status)
return QPixmap(":/images/ok.png");
}
}
return QVariant();
}
To copy to clipboard, switch view to plain text mode
As you can see I print som trace message when the DecorationRole is suposed to run but I get nothing, it never runs. I know there isn't much info but what can I have done wrong?
Bookmarks