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. Qt5 on Mac: List of windows in the Dock menu

Qt5 on Mac: List of windows in the Dock menu

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.0k 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.
  • D Offline
    D Offline
    dynamic
    wrote on last edited by
    #1

    Hello,
    normally, the list of app windows is shown in the Dock menu for a running app in Mac OS. Here is an example of Firefox:
    alt text
    However, this list is missing for an application, written in Qt. Is there any way to get it working?
    The only thing, I could find, was
    QMenu::setAsDockMenu()
    With this method, however, one would need to keep track of opened/closed windows manually, as far as I understand.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Looks like the right thing to do.

      You can automate the handling using destroyed signal.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mpergand
        wrote on last edited by mpergand
        #3

        As with any QMenu, you can listen to the aboutToShow() signal, like that:

        connect(dockMenu,SIGNAL(aboutToShow()),this,SLOT(dockMenuAboutToShow()));
        

        and in the dockMenuAboutToShow() slot:

        QMenu* menu=qobject_cast<QMenu*>(QObject::sender()); 
        if(menu==dockMenu)
           {
           // update the dock menu
        
           }
        
        1 Reply Last reply
        2
        • D Offline
          D Offline
          dynamic
          wrote on last edited by dynamic
          #4

          @SGaist and @mpergand,
          thanks for the tips! I will go for setAsDockMenu() then. It is interesting that apparently this feature worked automatically at some point in Qt 4, since it works, e.g., in an old version of DjView (v4.5), and they do not have any specific code for that, as far as I can tell.
          A naive question regarding the use of QMenu::aboutToShow(): Would not updating the list each time be noticeably slow, if one has, say, 30+ windows opened. I was thinking about updating the list immediately after a window is opened/closed etc., which seems to be more efficient.

          M 1 Reply Last reply
          0
          • D dynamic

            @SGaist and @mpergand,
            thanks for the tips! I will go for setAsDockMenu() then. It is interesting that apparently this feature worked automatically at some point in Qt 4, since it works, e.g., in an old version of DjView (v4.5), and they do not have any specific code for that, as far as I can tell.
            A naive question regarding the use of QMenu::aboutToShow(): Would not updating the list each time be noticeably slow, if one has, say, 30+ windows opened. I was thinking about updating the list immediately after a window is opened/closed etc., which seems to be more efficient.

            M Offline
            M Offline
            mpergand
            wrote on last edited by
            #5

            A naive question regarding the use of QMenu::aboutToShow(): Would not updating the list each time be noticeably slow

            I open over sixty windows and the dock menu appears in an instant.
            IMHO it's not a issue we should care about with modern computers.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              With that many windows opened, it might be of interest to consider some sort of grouping.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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