That's certainly a strange way to write a main() function. There is no need whatsoever to wrap either the QApplication instance or the MyMainForm instance in std::unique_ptr wrappers or to create them on the heap. If you construct your QApplication and MyMainForm on the stack, they are unique and will be destructed automatically when main() exits.

Not only that, but the code you've provided won't compile (two declarations of "app") so how are we know what your code really looks like? The best we can do with this is to start throwing out random guesses as to why it fails. The fact that you tried a smaller solution means that you are doing something wrong in this one.

Please use "CODE" tags when posting source code.