Minimize Application to dock icon.
I am making an appliation for MAC OSX 10.6.2 using Qt 4.7.
I want my application to hide to the dock icon on minimizing, but it doesn't hides to dock icon.
How can I do this, below is my code,
@if(evt->type() == QEvent::WindowStateChange)
//Now check to see if the window is minimised
// Call the Hide Slot after 100ms
// to prozess other events ....
QTimer::singleShot(100, this, SLOT(hide()));
} // Call original-handler (in this case QMainWindow ...) return QMainWindow::event(evt);@
What changes i should make in this code.
Also on clicking the dock icon, the application should be shown, if it was hidden or minimized, for this what should I do ?
Usually this is done automatically, you do not need to handle this.
The application has a dock icon as soon as it is started, regardless of the window states.
Cmd-M (or a click on the yellow button in the window title) minimizes the window. The window is shown as icon in the dock in addition to the application icon. Clicking on either of them restores the window.
Cmd-H hides the window. A window icon is not added to the dock, so you have only left the app icon. Clicking on that restores the window.
If you intercept the minimization of a window and change it to a hide, I'd consider this as a violation of the UI rules and something that I as a user would neither expect nor accept.
Actually what I wants is, on minimizing, the application should hide to the application icon and not to the window icon, and on clicking the application icon the application should be shown as normal.
The behavior I described is the expected behavior on the Mac and every application on the Mac I know of works exactly like this. I strongly recommend you adhere to the platform UI guidelines. Changing expected behavior annoys users and I strongly doubt that your application is the only one in the world that has that good reason to do so. So even if I knew a solution (I do not), I would not post it here.
The option you're asking for is not available even with the native (Cocoa + Objective-C) API. The behavior is actually available, but is offered as a global preference that effects all applications, instead of an application-specific setting. You can turn it on by enabling "Minimize windows into application icon" in System Preferences -> Dock.
Thanks Volker, I appreciate your advice and I had followed your suggestion.
I had solved that problem and following the MAC default behaviour.