Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Minimize Application to dock icon.

Minimize Application to dock icon.

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Ketan Shah
    wrote on 7 Oct 2011, 10:38 last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 7 Oct 2011, 10:51 last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Ketan Shah
        wrote on 7 Oct 2011, 11:30 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 7 Oct 2011, 20:01 last edited by
          #4

          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.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • U Offline
            U Offline
            uranusjr
            wrote on 7 Oct 2011, 20:31 last edited by
            #5

            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.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Ketan Shah
              wrote on 8 Oct 2011, 05:48 last edited by
              #6

              Thanks Volker, I appreciate your advice and I had followed your suggestion.
              I had solved that problem and following the MAC default behaviour.

              1 Reply Last reply
              0

              1/6

              7 Oct 2011, 10:38

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved