QStandardItemModel setIcon not working ?
-
Hi all,
I have a Qtableview showing data from a pandas dataframe using the QStandardItemModel.
I can set the color of a cel through:item=self.model.item(2,2) item.setBackground(QBrush(Qt.red))
But this doesn't work: item.setIcon(QtGui.QIcon("calendar.png"))
I tried different ways to call it but nothing works , i want to set an icon next to the text.Can anyone help ?
Cheers , John
-
Thx JonB , the file was in the same directory , after using absloute path it worked ;-)
-
Hi all,
I have a Qtableview showing data from a pandas dataframe using the QStandardItemModel.
I can set the color of a cel through:item=self.model.item(2,2) item.setBackground(QBrush(Qt.red))
But this doesn't work: item.setIcon(QtGui.QIcon("calendar.png"))
I tried different ways to call it but nothing works , i want to set an icon next to the text.Can anyone help ?
Cheers , John
@Johnson9070 said in QStandardItemModel setIcon not working ?:
QtGui.QIcon("calendar.png")
That is a relative path name, you do not know where your current working directory is. Use an appropriate absolute path.
-
Thx JonB , the file was in the same directory , after using absloute path it worked ;-)