那就是说你使用的是自定义的Model吧?那就实现data()中的Qt::DecorationRole角色返回的内容:
例如:
......
else if (role == Qt::DecorationRole)
{
switch (col)
{
case 0:
v = item[col].toInt() == 0 ?
QPixmap("://image/readnone.png") :
QPixmap(":/image/readover.png");;
break;
case 1:
if (item[col].toInt() == 1)
{
static QIcon icon;
if (icon.isNull())
{
icon.addPixmap(QPixmap(":/iMail/image/attachment.png"),
QIcon::Normal);
icon.addPixmap(QPixmap(
":/iMail/image/attachment_selected.png"),
QIcon::Selected);
}
v = icon;
}
break;
case 2:
v = item[col].toInt() == 0 ?
QPixmap(":/image/flaggray.png") :
QPixmap(":/image/flagred.png");
break;
default:;
}
}
else if (role == Qt::FontRole)
{
if (item[mfIsRead].toInt() == 0)
{
static QFont font;
font.setBold(true);
v = font;
// not read
}
}
......
return v;