Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53054

Sub menus open on the right click instead left when opening by click instead of hover (due to large values of QStyle::SH_Menu_SubMenuPopupDelay)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.6.2
    • 5.5.1, 5.6.0, 5.7.0 Beta
    • None
    • Windows, Linux
    • afa0e9bf6a53d20dbb9820c7fce1bb67de0e616f

    Description

      At least since Qt 5.5.1 sub menus open on the secondary mouse (right by default) button instead of the primary (left by default).

      This is in many cases with the default Windows setting barely noticeable. However, if the delay until a sub menu opens is prolonged then this effect is obvious and different from non-Qt based applications. Manually, this delay can be increased by changing in the registry (regedit.exe) under the folder

      HKEY_CURRENT_USER\Control Panel\Desktop

      the value of "MenuShowDelay" to a larger number, e.g. 4000 (instead of the default 400) or 40000 to make the delay "almost indefinitely". You need to log out and in again in order for the changes to apply.

      (The value is documented here: https://technet.microsoft.com/en-us/library/cc978617.aspx).

      This results in large values of QStyle::SH_Menu_SubMenuPopupDelay via SystemParametersInfo(SPI_GETMENUSHOWDELAY) at qtbase\src\widgets\styles\qwindowsstyle.cpp:590 .

      I believe setting this setting to a higher number normally enhances the easiness of navigating sub menus (especially for people whose motor skills are somewhat limited), since menus do not open and - what is more important - close as quickly. The opening and closing has to be manually triggered by a click.

      Steps to reproduce (for example in the attached minimal example):
      1. Open a main menu ("Main menu")
      2. Go to a sub menu (e.g. "Sub menu 1")
      3. Press immediately (depending on the MenuShowDelay, see above) the primary mouse button (the left by default)

      Actual result:

      • the sub menu does not open immediately upon the click

      Expected result:

      • the sub menu does open immediately upon the click

      Rather clicking the secondary mouse button achieves the expected result.

      I believe that there is a bug in Qt where the wrong mouse button is assigned to open sub menus. I have not seen this behavior in non Qt apps.

      The behavior might have gone unnoticed before because only since (at least) Qt 5.5.1 the "MenuShowDelay" setting seems to be respected by Qt. Before (at least) up to Qt 4 this setting had no effect whatsoever. Sub menus just opened after a very short delay irrespectively.

      There is another part of this bug (at least since) Qt 5.7 Beta. Even though it is possible to open a sub menu with a secondary mouse click, once a sub menu is opened it is not possible to open further sub menus without closing the main menu before.

      Steps to reproduce (for example in the attached minimal example):
      1. Open a main menu ("Main menu")
      2. Open a sub menu (e.g. "Sub menu 1")
      3. Go to another sub menu (e.g. "Sub menu 2")
      4. Press immediately (depending on the MenuShowDelay, see above) the secondary mouse button (the left by default)

      This time not even the secondary click triggers the (from the primary click) expected behavior. In order to make the secondary click have again the effect as explained above one has to first close the main menu and reopen it again.

      Attachments

        1. main.cpp
          0.5 kB
        2. mainwindow.h
          0.3 kB
        3. menus.pro
          0.2 kB
        4. qtbug53054_qt5_repro.diff
          1 kB
        5. qtbug53054.zip
          2 kB
        6. screencapture.avi
          98 kB
        7. Sub_menu_not_opening_on_click_highlighted.png
          Sub_menu_not_opening_on_click_highlighted.png
          3 kB
        For Gerrit Dashboard: QTBUG-53054
        # Subject Branch Project Status CR V

        Activity

          People

            zaps166 Błażej Szczygieł
            racoon racoon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes