PDA

View Full Version : Break system shutdown when in my program I want minimize instead close.



jmj
15th August 2010, 10:59
I don't know how properly write program which will minimize instead close, and which do not prevent system from close (when I want restart system or shutdown). For now when my program is showed (window is visible for user) and I click close system, then closing system is break by my program and my program is minimized. I cant find out how to handle this special case when program should close instead minimize.... Please help me.

The Storm
15th August 2010, 11:13
Check out QApplication::commitDataRequest() signal. By default when the system is going to shutdown will emit this signal and if you don't get it QApplication will send closeEvent to all the opened windows, if any window ignore the close event(like you are doing when minimizing) the shutdown will be canceled. To avoid such a case just connect to that signal(note you should explicitly use Qt::DirectConnection for this signal as the documentation says) and rise some flag or send some custom event to your windows in order to let them know that when they receive closeEvent they must accept it.