Minimize Application to dock icon.
-
wrote on 7 Oct 2011, 10:38 last edited by
Hi,
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
if (isMinimized())
{
// Call the Hide Slot after 100ms
// to prozess other events ....
qApp->processEvents();
QTimer::singleShot(100, this, SLOT(hide()));
evt->ignore();
}} // 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 ? -
wrote on 7 Oct 2011, 10:51 last edited by
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.
-
wrote on 7 Oct 2011, 11:30 last edited by
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.
-
wrote on 7 Oct 2011, 20:01 last edited by
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.
-
wrote on 7 Oct 2011, 20:31 last edited by
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.
-
wrote on 8 Oct 2011, 05:48 last edited by
Thanks Volker, I appreciate your advice and I had followed your suggestion.
I had solved that problem and following the MAC default behaviour.
1/6