When you run a pyqt program, normally the uncaught errors will be printed to the console. But my program is compiled into a windowed executable with pyinstaller, so afaik, there's no way to get to the stderr.
So I'd like to catch the unexpected errors and log them to file. Sort of like the Qt equivalent of "putting the whole program in a try block". I just can't can't figure out where to catch the errors.
Let's take this basic example:
class Window(QWidget):
def __init__(self):
super().__init__()
but = QPushButton('oops')
but.clicked.connect(lambda: 3 / 0)
layout = QVBoxLayout(self)
layout.addWidget(but)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())
Where would you catch the ZeroDivisionError or any other error that slips through the cracks?