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.
Bookmarks