qttreepropertybrowser.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:QtPropertyBrowserV2.6-for-pyqt5 作者: theall 项目源码 文件源码
def paint(self, painter, option, index):
        hasValue = True
        if (self.m_editorPrivate):
            property = self.m_editorPrivate.indexToProperty(index)
            if (property):
                hasValue = property.hasValue()

        opt = QStyleOptionViewItem(option)
        if ((self.m_editorPrivate and index.column() == 0) or not hasValue):
            property = self.m_editorPrivate.indexToProperty(index)
            if (property and property.isModified()):
                opt.font.setBold(True)
                opt.fontMetrics = QFontMetrics(opt.font)

        c = QColor()
        if (not hasValue and self.m_editorPrivate.markPropertiesWithoutValue()):
            c = opt.palette.color(QPalette.Dark)
            opt.palette.setColor(QPalette.Text, opt.palette.color(QPalette.BrightText))
        else:
            c = self.m_editorPrivate.calculatedBackgroundColor(self.m_editorPrivate.indexToBrowserItem(index))
            if (c.isValid() and (opt.features & QStyleOptionViewItem.Alternate)):
                c = c.lighter(112)

        if (c.isValid()):
            painter.fillRect(option.rect, c)
        opt.state &= ~QStyle.State_HasFocus

        if (index.column() == 1):
            item = self.m_editorPrivate.indexToItem(index)
            if (self.m_editedItem and (self.m_editedItem == item)):
                self.m_disablePainting = True

        super(QtPropertyEditorDelegate, self).paint(painter, opt, index)
        if (option.type):
            self.m_disablePainting = False

        opt.palette.setCurrentColorGroup(QPalette.Active)
        color = QApplication.style().styleHint(QStyle.SH_Table_GridLineColor, opt)
        painter.save()
        painter.setPen(QPen(color))
        if (not self.m_editorPrivate or (not self.m_editorPrivate.lastColumn(index.column()) and hasValue)):
            if option.direction == Qt.LeftToRight:
                right = option.rect.right()
            else:
                right = option.rect.left()
            painter.drawLine(right, option.rect.y(), right, option.rect.bottom())

        painter.restore()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号