PyQt Vertical Header Icons?
Hoping to emplace an (repetitive) icon for each vertical header (row).
Currently the header 'box' is empty; without any text - yet efforts to set via headerData() function in AbstractTableModel do not seem to work.
Below is the current non-functioning script(s):
Code:
def headerData(self,section,orientation,role):
if role != Qt.DisplayRole:
return
if orientation == Qt.Vertical and role == Qt.DecorationRole:
return QtGui.
QIcon(r
'C:\Program Files\QGIS Brighton\apps\qgis\python\plugins\GraphicGroundwater\buttons\zoomAndDrag.png')
if orientation == Qt.Horizontal:
return self.header[section]
Thousand thanks for any clues.
Re: PyQt Vertical Header Icons?
You are returning if the role is not Qt.DisplayRole, which means your next if statement can never be true.
[SOLVED] PyQt Vertical Header Icons?
jthomps,
Ridiculous I didn't realize that. Thank you.
The following got things working (although I suppose the first if-pass statement isn't all together necessary):
Code:
def headerData(self,section,orientation,role):
if role != Qt.DisplayRole:
pass
if orientation == Qt.Vertical and role == Qt.DecorationRole:
return QtGui.
QIcon(r
'...\buttons\zoomAndDrag.png') if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self.header[section]
Again, a thousand thanks jthomps.