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

  • 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.

  • 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.

  • 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.

  • Moderators

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

  • I use QToolButton with InstantPopup popup mode

Log in to reply