當前位置: 首頁>>代碼示例>>Python>>正文


Python QStyleOption.rect方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QStyleOption.rect方法的典型用法代碼示例。如果您正苦於以下問題:Python QStyleOption.rect方法的具體用法?Python QStyleOption.rect怎麽用?Python QStyleOption.rect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QStyleOption的用法示例。


在下文中一共展示了QStyleOption.rect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: drawIndicatorIcon

# 需要導入模塊: from PyQt5.QtWidgets import QStyleOption [as 別名]
# 或者: from PyQt5.QtWidgets.QStyleOption import rect [as 別名]
def drawIndicatorIcon(palette, style):
    pix = QPixmap(14, 14)
    pix.fill(Qt.transparent)
    branchOption = QStyleOption()
    #r = QRect(QPoint(0, 0), pix.size())
    branchOption.rect = QRect(2, 2, 9, 9) ## ### hardcoded in qcommonstyle.cpp
    branchOption.palette = palette
    branchOption.state = QStyle.State_Children

    p = QPainter()
    ## Draw closed state
    p.begin(pix)
    style.drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, p)
    p.end()
    rc = QIcon(pix)
    rc.addPixmap(pix, QIcon.Selected, QIcon.Off)
    ## Draw opened state
    branchOption.state |= QStyle.State_Open
    pix.fill(Qt.transparent)
    p.begin(pix)
    style.drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, p)
    p.end()

    rc.addPixmap(pix, QIcon.Normal, QIcon.On)
    rc.addPixmap(pix, QIcon.Selected, QIcon.On)
    return rc
開發者ID:theall,項目名稱:QtPropertyBrowserV2.6-for-pyqt5,代碼行數:28,代碼來源:qttreepropertybrowser.py

示例2: paintEvent

# 需要導入模塊: from PyQt5.QtWidgets import QStyleOption [as 別名]
# 或者: from PyQt5.QtWidgets.QStyleOption import rect [as 別名]
 def paintEvent(self, event):
     QToolButton.paintEvent(self, event)
     painter = QPainter(self)
     opt = QStyleOption()
     opt.initFrom(self)
     opt.rect = QRect(6, self.rect().center().y() - 3, 8, 8)
     opt.rect.translate(0, -3)
     style = self.style()
     style.drawPrimitive(QStyle.PE_IndicatorArrowUp, opt, painter, self)
     opt.rect.translate(0, 6)
     style.drawPrimitive(QStyle.PE_IndicatorArrowDown, opt, painter, self)
開發者ID:ninja-ide,項目名稱:ninja-ide,代碼行數:13,代碼來源:tools_dock.py

示例3: paint_drop_indicator

# 需要導入模塊: from PyQt5.QtWidgets import QStyleOption [as 別名]
# 或者: from PyQt5.QtWidgets.QStyleOption import rect [as 別名]
    def paint_drop_indicator(self, painter):
        if self.drag_active:
            opt = QStyleOption()
            opt.initFrom(self)
            opt.rect = self.drop_indicator_rect
            rect = opt.rect

            brush = QBrush(QColor(Qt.darkRed))

            if rect.height() == 0:
                pen = QPen(brush, 2, Qt.SolidLine)
                painter.setPen(pen)
                painter.drawLine(rect.topLeft(), rect.topRight())
            else:
                pen = QPen(brush, 2, Qt.SolidLine)
                painter.setPen(pen)
                painter.drawRect(rect)
開發者ID:Cyber-Forensic,項目名稱:urh,代碼行數:19,代碼來源:GeneratorTableView.py


注:本文中的PyQt5.QtWidgets.QStyleOption.rect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。