anyone know how to make my program stay open with no mainwindow?

I have a program that when runs the mainwindow constructor doesn't show the mainwindow, it just creates a tray icon and a keyboard hook, and then shows windows as needed

problem is if a dialog is displayed when it closes qt quits altogehter, I can't keep my program alive in the tray

thanks in advance for the help and if you want code just ask and I can post some stuff