QTreeView and itemDelegate code
This code worked just fine some months ago (maybe half year), and now it's not working. Why could it be? Message error is ''NoneType' object has no attribute 'style'' from line 12.
Code:
def paint(self, painter, option, index):
if not index.isValid():
return
painter.translate(0, 0)
options = QStyleOptionViewItemV4(option)
self.initStyleOption(options, index)
painter.save()
painter.
setRenderHint(QPainter.
Antialiasing,
True) doc.setHtml(options.text)
options.text = ""
options.
widget.
style().
drawControl(QStyle.
CE_ItemViewItem, options, painter, options.
widget) #<---ERROR painter.translate(options.rect.left() + self.sizeDp(index) + 3, options.rect.top()) #paint text right after the dp + 3pixels
rect
= QRectF(0,
0, options.
rect.
width(), options.
rect.
height()) doc.drawContents(painter, rect)
painter.restore()
Why could this be happening?
Re: QTreeView and itemDelegate code
the solution was
options.widget.style().drawControl(QStyle.CE_ItemV iewItem, options, painter, options.widget) #<---ERROR
QApplication.style().drawControl(QStyle.CE_ItemVie wItem, options, painter, options.widget)