Hmmm, now I figured out something. I can leave constructor as in first post (without while loop), but just comment out following line in main.cpp:

//w.show();

and it works as intended (launches program, shows dialog box when program exits and stays completely hidden). Does this have any side effect?