How do I convert a QStyleOptionViewItem into a QStyleOptionViewItemV4? Qt has the qstyleoption_cast() method, but no such method exists in PyQt4.
I have my own subclass of QStyledItemDelegate and have overridden the initStyleOption() method so that I can provide my own foreground/background colors, fonts, etc. The problem I'm running into is with the background color -- I need to set the backgroundBrush attribute, which is only available on QStyleOptionViewItemV4. So I need to somehow cast the QStyleOptionViewItem object into a QStyleOptionViewItemV4 object... from PyQt4 import * class MyItemDelegate(QStyledItemDelegate): def initStyleOption(self, option, index): QStyledItemDelegate.initStyleOption(self, option, index) # set font family and color option.font.setFamily("Courier") option.palette.setBrush(QPalette.Text, QtCore.Qt.red) # set background color # this doesn't work: option.backgroundBrush = QBrush(QtCore.Qt.black) # neither does this: option = QStyleOptionViewItemV4(option) option.backgroundBrush = QBrush(QtCore.Qt.black)
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt