本文整理汇总了Python中AnyQt.QtWidgets.QLineEdit.event方法的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit.event方法的具体用法?Python QLineEdit.event怎么用?Python QLineEdit.event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComboBoxSearch
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import event [as 别名]
#.........这里部分代码省略.........
popup.viewport().setMouseTracking(True)
self.update()
self.__popupTimer.restart()
def hidePopup(self):
"""Reimplemented"""
if self.__popup is not None:
popup = self.__popup
self.__popup = self.__proxy = None
popup.setFocusProxy(None)
popup.hide()
popup.deleteLater()
popup.removeEventFilter(self)
popup.viewport().removeEventFilter(self)
# need to call base hidePopup even though the base showPopup was not
# called (update internal state wrt. 'pressed' arrow, ...)
super().hidePopup()
self.__searchline.hide()
self.update()
def initStyleOption(self, option):
# type: (QStyleOptionComboBox) -> None
super().initStyleOption(option)
option.editable = True
def __updateGeometries(self):
opt = QStyleOptionComboBox()
self.initStyleOption(opt)
editarea = self.style().subControlRect(
QStyle.CC_ComboBox, opt, QStyle.SC_ComboBoxEditField, self)
self.__searchline.setGeometry(editarea)
def resizeEvent(self, event):
"""Reimplemented."""
super().resizeEvent(event)
self.__updateGeometries()
def paintEvent(self, event):
"""Reimplemented."""
opt = QStyleOptionComboBox()
self.initStyleOption(opt)
painter = QStylePainter(self)
painter.drawComplexControl(QStyle.CC_ComboBox, opt)
if not self.__searchline.isVisibleTo(self):
opt.editable = False
painter.drawControl(QStyle.CE_ComboBoxLabel, opt)
def eventFilter(self, obj, event): # pylint: disable=too-many-branches
# type: (QObject, QEvent) -> bool
"""Reimplemented."""
etype = event.type()
if etype == QEvent.FocusOut and self.__popup is not None:
self.hidePopup()
return True
if etype == QEvent.Hide and self.__popup is not None:
self.hidePopup()
return False
if etype == QEvent.KeyPress or etype == QEvent.KeyRelease or \
etype == QEvent.ShortcutOverride and obj is self.__popup:
event = event # type: QKeyEvent
key, modifiers = event.key(), event.modifiers()
if key in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Select):
current = self.__popup.currentIndex()
if current.isValid():