Reputation: 93
code first:
class MyWidget(QMainWindow)
def __init__(self):
super(MyWidget, self).__init__()
self.setMinimumSize(900, 500)
self.setMouseTracking(True)
def mousePressEvent(self, e):
if e.buttons() == Qt.LeftButton:
print('left pressed')
elif e.buttons() == Qt.RightButton:
print('right pressed')
else:
print('other button pressed')
def mouseReleaseEvent(self, e):
if e.buttons() == Qt.LeftButton:
print('left up')
elif e.buttons() == Qt.RightButton:
print('right up')
else:
print('other up')
just press the LEFT button, it outputs 'left pressed', but when release the LEFT button, it outputs 'other up', instead of 'left up'!!
it happens to the RIGHT button in the same way.
Upvotes: 0
Views: 108