Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
PyQt5 - self.hide causes app to terminate
I am currently writing my first project based on PyQt5. You can find the source here: https://github.com/corelan/pyencfsgui
For some reason, when I try to hide the main window using self.hide(), the application terminates.
Does anyone know what I'm doing wrong?
Do you mean you would like your GUI application to continue running even without any widget available ?
By the way, what version of PyQt5 or PySide2 are you using ?
On what OS ?
@SGaist nvm fixed it - to launch my app, I was using <mainwindow>.exec_ instead of app.exec_. Doing a self.hide on the mainwindow made it terminate. Changing it to app.exec_ fixed it.
JonB last edited by
For the record: hiding/closing the main window made your application terminate because of https://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop
This property holds whether the application implicitly quits when the last window is closed.
The default is
If this property is
true, the applications quits when the last visible primary window (i.e. window with no parent) is closed.
@JonB cool, good to know ! :)