Skip to content

Instantly share code, notes, and snippets.

@eyllanesc
Created Dec 24, 2018
Embed
What would you like to do?
from PyQt5 import QtCore, QtWidgets
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self._gv = QtWidgets.QGraphicsView()
self.setCentralWidget(self._gv)
self._gv.viewport().installEventFilter(self)
def eventFilter(self, obj, event):
if obj is self._gv.viewport() and event.type() == QtCore.QEvent.MouseButtonDblClick:
print(obj, event)
return super(MainWindow, self).eventFilter(obj, event)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment