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


Python QLineEdit.paintEvent方法代碼示例

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


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

示例1: paintEvent

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import paintEvent [as 別名]
    def paintEvent(self, event):
        """QLineEdit.paintEvent implementation.
        Draws prompt
        """
        QLineEdit.paintEvent(self, event)

        if self._promptText and not self.text() and self.isEnabled():
            option = QStyleOptionFrameV3()
            self.initStyleOption(option)

            left, top, right, bottom = self.getTextMargins()

            va = self.style().visualAlignment(self.layoutDirection(), self.alignment())
            rect = (
                self.style()
                .subElementRect(QStyle.SE_LineEditContents, option, self)
                .adjusted(2, 0, 0, 0)
                .adjusted(left, top, -right, -bottom)
            )
            fm = QFontMetrics(self.font())
            text = fm.elidedText(self._promptText, Qt.ElideRight, rect.width())
            painter = QPainter(self)

            painter.setPen(self.palette().color(QPalette.Disabled, QPalette.Text))
            painter.drawText(rect, va, text)
開發者ID:gpa14,項目名稱:enki,代碼行數:27,代碼來源:lineedit.py

示例2: paintEvent

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import paintEvent [as 別名]
 def paintEvent(self, event):
     QLineEdit.paintEvent(self, event)
     if self.base_unit:
         panel = QStyleOptionFrame()
         self.initStyleOption(panel)
         textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
         textRect.adjust(2, 0, -10, 0)
         painter = QPainter(self)
         painter.setPen(self.help_palette.brush(QPalette.Disabled, QPalette.Text).color())
         painter.drawText(textRect, Qt.AlignRight | Qt.AlignVCenter, self.base_unit())
開發者ID:bygage,項目名稱:electrum,代碼行數:12,代碼來源:amountedit.py

示例3: paintEvent

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import paintEvent [as 別名]
 def paintEvent(self, event):
     QLineEdit.paintEvent(self, event)
     if not self.hasFocus() and not self.text() and self.inactiveText:
         options = QStyleOptionFrame()
         self.initStyleOption(options)
         text_rect = self.style().subElementRect(QStyle.SE_LineEditContents, options, self)
         text_rect.adjust(self.left_margin+2, 0, -self.right_margin, 0)
         painter = QPainter(self)
         painter.setPen(self.palette().brush(QPalette.Disabled, QPalette.Text).color())
         painter.drawText(text_rect, Qt.AlignLeft | Qt.AlignVCenter, self.inactiveText)
開發者ID:AGProjects,項目名稱:blink-qt,代碼行數:12,代碼來源:lineedit.py

示例4: paintEvent

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import paintEvent [as 別名]
 def paintEvent(self, event):
     QLineEdit.paintEvent(self, event)
     if not bool(self.text()) and self.inactiveText and not self.hasFocus():
         panel = QStyleOptionFrame()
         self.initStyleOption(panel)
         textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
         leftMargin = 2
         rightMargin = self._clearButton.iconSize().width()
         textRect.adjust(leftMargin, 0, -rightMargin, 0)
         painter = QPainter(self)
         disabledColor = self.palette().brush(QPalette.Disabled, QPalette.Text).color()
         painter.setPen(disabledColor)
         painter.drawText(textRect, Qt.AlignLeft|Qt.AlignVCenter, self.inactiveText)
開發者ID:Arasy,項目名稱:dupeguru,代碼行數:15,代碼來源:search_edit.py


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