Re: Problem quitting QApplication using qt_app.exec_()
I'm also a Python beginner, so please take my words with a little pinch of salt, but I can at least explain the first problem.
What does your fnQuit_button_clicked(self) code do? It *executes the application*, and when the application finishes, it quits with its return code. Not only that, but instead of an application, you're trying to execute a widget, which actually generates the error...
Also, I'd say it's at least confusing that you're trying to instantiate your widget as a variable called "app", which is the source of confusion that led to this problem. And then you "run" the widget, which actually launches the application.
I'd suggest to stick to the "normal" way of doing those things.
First of all, change the three bottom lines to the following:
myapp = QApplication(sys.argv) # Instantiate a QApplication
mywidget = LayoutExample() # Instantiate my widget
sys.exit(myapp._exec()) # Launch the application and exit with its return code
Then, move self.show() to the constructor, and remove the run() function. The widget shows itself after it's constructed, and you don't "run" a widget.
And finally, your Quit button should simply call self.close() . In this case, I would not even create a separate function for this; instead, I would simply connect the button directly to self.close (remember, without "()", since we are passing it and not executing it!). When this widget is closed, the application will exit.