def test_close (): app = QApplication(sys.argv) ex = Example() ale = Ale () # install globally app.installEventFilter (ale) sys.exit(app.exec_())