Dup Ver Goto 📝

MouseEvents1

To
21 lines, 58 words, 494 chars Page 'MouseEvents1' does not exist.

This shows how to use different mouse buttons and modifiers.

from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *

class W(QLabel):
  def mousePressEvent(self,e):
    print(e)
    mods = e.modifiers().value
    button = e.button()
    print("left", button == Qt.LeftButton)
    print("right", button == Qt.RightButton)
    shift = Qt.ShiftModifier.value
    print("shift", shift&mods != 0)

app = QApplication([])
w = W("hello")
w.show()
app.exec()