There is nothing wrong with either of those code fragments.

What tools you use to build the executable are irrelevant. But, if you are compiling against Qt5 headers and libraries and your runtime is loading an incompatible version of the shared libraries, that could cause a crash.