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. QMenu element doesn't close at clicking on title bar of QMainWindow
QtWS25 Last Chance

QMenu element doesn't close at clicking on title bar of QMainWindow

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.5k 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.
  • A Offline
    A Offline
    Arus1
    wrote on last edited by
    #1

    After porting desktop application from QT 4.8.4 to QT 5.2 a drop down menu of type QMenu fails to close at clicking on title bar of QMainWindow, whereas the menu disappears when the focus is switched to any other element.
    How can I solve the issue?
    Thanks in advance.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      It probably has to do with the fact that a QMenu is a toplevel widget. When clicked on an other toplevel widget (the menu bar) the event will not be given to the drop down menu. When clicked on the mainWidget it will.
      Maybe implement the focusEvent in the menu so that when the mouse moves off the menu, you close it? Otherwise in the QMenu that you click, also direct the event to the dropdown menu.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Arus1
        wrote on last edited by
        #3

        The QMenu widget was top-level, I set QMainWindow as patent, and now the QMenu closes when clicking on the title of QMainWindow.
        But now there is another problem, QMenu remains open when I click outside of QMainWindow.
        Could you suggest a solution for this issue?
        This bug detected on Mac OS.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          do you use QMenu::exec() to show the menu or show()?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Arus1
            wrote on last edited by
            #5

            I use QToolButton with InstantPopup popup mode

            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