put qt gui launching code into a function