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

QWidget inside a QMenu using QWidgetAction does not always receive enterEvent and leaveEvent

    XMLWordPrintable

Details

    • macOS, Windows
    • 40bde8a57 (dev), cd528d81f (6.8)

    Description

      A QWidget inside a QMenu using QWidgetAction does not always receive enterEvent and leaveEvent.

       

      What I did :

      I implemented a custom widget to add inside a QMenu using QWidgetAction.

      I wanted this widget to have a darker background on mouse hover.

      I implemented enterEvent and leaveEvent to achieve this.

       

      What I expected to happen :

      When my mouse leaves a widget and enters another one, I expect the widget my mouse leaves to receive a leaveEvent and the widget it enters a enterEvent.

       

      What happened instead :

      This works most of the time, but for some reason sometimes an item does not receive an enterEvent or a leaveEvent, resulting in :

      • an item that is not hovered anymore still having a darker background
      • an item that is hovered not having a darker background

       

      Additional informations :

      It's not related to my custom widget implementation. This bug is reproductible with any widget. Replacing my widget by a QPushButton will result in the button sometimes not receiving mouse leave events and staying hovered.

      Attachments

        1. bug.png
          bug.png
          6 kB
        2. bug-reproducer.zip
          5 kB
        3. qwidgetaction-enter-leave.cpp
          2 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              dfaure_kdab David Faure
              pribault Paul Ribault
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes