Goswin von Brederlow
Goswin von Brederlow

Reputation: 12362

How to remove an icon in a QTreeWidgetItem?

I have a QTreeWidget with QTreeWidgetItems and sometimes the items have an icon. So I set the icon using:

self.setIcon(0, icon)

But how do I remove that icon again?

self.setIcon(0, None)

gives

TypeError: 'PySide.QtGui.QTreeWidgetItem.setIcon' called with wrong argument types:
  PySide.QtGui.QTreeWidgetItem.setIcon(int, NoneType)
Supported signatures:
  PySide.QtGui.QTreeWidgetItem.setIcon(int, PySide.QtGui.QIcon)

Upvotes: 3

Views: 3880

Answers (1)

NoDataDumpNoContribution
NoDataDumpNoContribution

Reputation: 10864

For completeness I write down the comment of vahancho as an answer.

Set an empty icon:

item.setIcon(column, QtGui.QIcon())

This also makes sense since even without setting an icon

item.icon(column)

does return a QIcon object. So Qt probably internally presets the icons with empty icons anyway.

Upvotes: 5

Related Questions