(self, painter, option, index)
| 23 | class NoColorItemDelegate(QStyledItemDelegate): |
| 24 | |
| 25 | def paint(self, painter, option, index): |
| 26 | if option.state & QStyle.State_HasFocus: |
| 27 | # 取消虚线框 |
| 28 | option.state = option.state & ~ QStyle.State_HasFocus |
| 29 | if option.state & QStyle.State_MouseOver and index.data(Qt.UserRole + 1): |
| 30 | # 不显示鼠标悬停颜色 |
| 31 | option.state = option.state & ~ QStyle.State_MouseOver |
| 32 | super(NoColorItemDelegate, self).paint(painter, option, index) |
| 33 | |
| 34 | |
| 35 | class Window(QTreeWidget): |