My main file for a pyqt application looks like this:
#!/usr/bin/env python3from PyQt5.QtWidgets import QApplicationimport signalimport sysfrom main_window import MainWindowif __name__ == "__main__": signal.signal(signal.SIGINT, signal.SIG_DFL) app = QApplication([]) window = MainWindow() window.show() app.exec()
It works, and when I ctrl-c in the terminal (on Ubuntu) the application will terminate...
...unless it creates a QOpenGLWidget, in which case ctrl-C does nothing.
I tried this
def signal_handler(signum, frame):"""Handle SIGINT signal""" print("\nReceived SIGINT, closing application...") QApplication.instance().quit()if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) ...
but signal_handler
is never called.
How can I terminate a pyqt application using QOpenGLWidget using ctrl-C from the terminal?