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

QToolButton and QPushButton is not compatible with QMenu::show()

    XMLWordPrintable

Details

    • Linux/X11, macOS

    Description

      By subclassing a QToolButton or a QPushButton (or maybe any subclasses of QAbstractButton - haven't tested yet) and overriding its contextMenuEvent so that a QMenu::shown() is called within, the button cannot handle release correctly.

      The bugged behavior goes like: if left-click is held as it is and then a right-click is also registered, releasing left button or both buttons won't make button release, while it can be released if no shown() is called. Also, creating menu, setting attribute and adding actions to menu won't trigger such behavior, i.e., the reason is solely related to shown().

      It can be avoided by left-clicking on button again, or connect destroyed() signal of menu to setDown(false) method of button. But it is better to know what causes such behavior. Is it really a bug or designed to avoid some other issues?

      A minimum reproducer is uploaded. Run the app, click the button as described above and issue can be reproduced.

      Attachments

        1. ButtonIssue.zip
          11 kB
          Luqiao Chen
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            luqiaochen Luqiao Chen
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes