JPNaude
13th October 2008, 17:35
Hi
I'm trying to display an icon in a tableview cell. I've search this forum but only found one thread related to it:
http://www.qtcentre.org/forum/showthread.php?t=6136&highlight=icon+tableview
However this does not help me since that was a tableWidget. I've created a model class inheriting from QAbstractTableModel and in the data() function I'm trying to return a QIcon. I thought this would work since the data function returns a QVariant which should suit a QIcon.
This is the code that is located in my model's data function:
if (role == Qt::DisplayRole) {
QIcon icon = QIcon(":/images/error.png");
return icon
}
Am I missing something? Can I use a .png file? This should be pretty easy to do shouldn't it?
Thanks
Jaco
I'm trying to display an icon in a tableview cell. I've search this forum but only found one thread related to it:
http://www.qtcentre.org/forum/showthread.php?t=6136&highlight=icon+tableview
However this does not help me since that was a tableWidget. I've created a model class inheriting from QAbstractTableModel and in the data() function I'm trying to return a QIcon. I thought this would work since the data function returns a QVariant which should suit a QIcon.
This is the code that is located in my model's data function:
if (role == Qt::DisplayRole) {
QIcon icon = QIcon(":/images/error.png");
return icon
}
Am I missing something? Can I use a .png file? This should be pretty easy to do shouldn't it?
Thanks
Jaco