Important: Please read the Qt Code of Conduct -

[SOLVED] QMenu: inadequate delay to mouse over a submenu

  • Has anyone else noticed the poor behavior of QMenu in regards to displaying submenus (at least on Windows - haven't yet tried other platforms)? If you move the mouse diagonally to the submenu, causing the mouse to temporarily hover over an item in the top-level menu, it's difficult to get to the submenu. For example, if you have this menu structure:

    Item2 |SubmenuItem1
    Item3 |SubmenuItem2
    Item4 |SubmenuItem3

    Hover over Item1 to display the submenu.

    Start moving the mouse down and to the right toward SubmenuItem3.

    The mouse temporarily hovers over Item2 through Item4 (not necessarily all of them).

    Continue moving to where SubmenuItem3 should be.

    Qt has hidden the submenu, because you hovered over Item2 through Item4.

    This is quite aggravating. Does anyone know if there is a way to increase the amount of delay Qt provides to mouse over to a submenu?

    The layout file here demonstrates the issue. Just load it into Designer, and run it from there.

  • After some spelunking in qmenu.cpp, I learned this is controlled by the style hint QStyle::SH_Menu_SloppySubMenus. This returns 0 by default on Windows. Making it return 1 (by installing my own style proxy, via QApplication::setStyle) gets me the improved behavior that is the default on the Mac.

Log in to reply