本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsScene.keyPressEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsScene.keyPressEvent方法的具体用法?Python QGraphicsScene.keyPressEvent怎么用?Python QGraphicsScene.keyPressEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsScene
的用法示例。
在下文中一共展示了QGraphicsScene.keyPressEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsScene [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsScene import keyPressEvent [as 别名]
def keyPressEvent(self, event):
QGraphicsScene.keyPressEvent(self, event)
if event.key() == Qt.Key_F:
if not self.insert_mode:
self.velocity_mode = False
self.insert_mode = True
self.makeGhostNote(self.mousePos.x(), self.mousePos.y())
self.modeupdate.emit('insert_mode')
elif self.insert_mode:
self.insert_mode = False
if self.place_ghost: self.place_ghost = False
self.removeItem(self.ghost_note)
self.ghost_note = None
self.modeupdate.emit('')
elif event.key() == Qt.Key_D:
if self.velocity_mode:
self.velocity_mode = False
self.modeupdate.emit('')
else:
if self.insert_mode:
self.removeItem(self.ghost_note)
self.ghost_note = None
self.insert_mode = False
self.place_ghost = False
self.velocity_mode = True
self.modeupdate.emit('velocity_mode')
elif event.key() == Qt.Key_A:
if all((note.isSelected() for note in self.notes)):
for note in self.notes:
note.setSelected(False)
self.selected_notes = []
else:
for note in self.notes:
note.setSelected(True)
self.selected_notes = self.notes[:]
elif event.key() in (Qt.Key_Delete, Qt.Key_Backspace):
self.notes = [note for note in self.notes if note not in self.selected_notes]
for note in self.selected_notes:
self.removeItem(note)
self.midievent.emit(["midievent-remove", note.note[0], note.note[1], note.note[2], note.note[3]])
del note
self.selected_notes = []