首先——感谢你们的支持!一个月前我开始研究PyQt。在那段时间里,我遇到了很多问题,事实上总能在这里找到答案。在
直到现在。在
我有一个解决办法,但我认为这是一个愚蠢的,可能有一个适当的方法。我想更好地了解发生了什么事。在
代码如下:from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class FormWidget(QWidget):
def __init__(self, parent):
super(FormWidget, self).__init__(parent)
# Create view with image in it
self.image = QGraphicsPixmapItem(QPixmap())
self.scene = QGraphicsScene()
self.scene.addItem(self.image)
self.view = QGraphicsView(self.scene)
self.hlayout = QHBoxLayout()
self.hlayout.addWidget(self.view)
self.setLayout(self.hlayout)
# self.view.keyPressEvent = self.keyPressEvent
def keyPressEvent(self, event):
key = event.key()
mod = int(event.modifiers())
print(
&#