Although there's no direct way to tell that, you can use QEvent::spontaneous() to see if the event came from outside the app. Since the title bar is being managed by the platform window manager it seems logical that a QCloseEvent issued by pressing the close button will be spontaneous. If my assumption is true then you can figure out how to use the value of QEvent::spontaneous().
You marcel are a genius. clicking the "X" returned true and a call to close() from the creating runtime returned false.
Bookmarks