本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsTextItem.keyPressEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsTextItem.keyPressEvent方法的具体用法?Python QGraphicsTextItem.keyPressEvent怎么用?Python QGraphicsTextItem.keyPressEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsTextItem
的用法示例。
在下文中一共展示了QGraphicsTextItem.keyPressEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import keyPressEvent [as 别名]
def keyPressEvent(self, event):
'''Handle key pressed event.
Argument(s):
event (QKeyEvent): Key event
'''
QGraphicsTextItem.keyPressEvent(self, event)
self.parentItem().updateShapeAndEdges()
示例2: textkeyPressEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import keyPressEvent [as 别名]
def textkeyPressEvent(self, event):
"""
Must intercept invalid input events. Make changes here
"""
a = event.key()
text = event.text()
if a in [Qt.Key_Space, Qt.Key_Tab]:
return
elif a in [Qt.Key_Return, Qt.Key_Enter]:
self.inputMethodEventHandler(event)
return
# elif unicode(text).isalpha():
elif text.isalpha():
return
else:
return QGraphicsTextItem.keyPressEvent(self._label, event)
示例3: keyPressEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import keyPressEvent [as 别名]
def keyPressEvent(self, event: QKeyEvent):
"""Must intercept invalid input events. Make changes here
"""
a = event.key()
text = event.text()
if a in [Qt.Key_Space, Qt.Key_Tab]:
return
elif a in [Qt.Key_Escape]:
self.updateLabel()
self.focusOut()
return
elif a in [Qt.Key_Return, Qt.Key_Enter]:
self.inputMethodEvent(event)
return
elif text.isalpha():
return
else:
return QGraphicsTextItem.keyPressEvent(self, event)
示例4: keyPressEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import keyPressEvent [as 别名]
def keyPressEvent(self, e):
QGraphicsTextItem.keyPressEvent(self, e)
self.parentItem().update()