Re: QWidgetAction doesn't allow app to quit
Considering you haven't told us anything about where this code actually gets executed, and what happens inside the "..." of the first line, it's pretty much impossible to say what the error is.
My guess is that in the first line you are creating a new MainWindow instance (and different from the one you create in main()), so you end up with an app that has multiple instances of MainWindow running at the same time.
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.