Results 1 to 4 of 4

Thread: QEvent::MouseButtonRelease with QEvent::Leave

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2017
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QEvent::MouseButtonRelease with QEvent::Leave

    I have multiple widgets for which I want to implement the following functionality:

    If the mouse hovers away from the widget, and then a mouse click occurs anywhere outside the widget , then I have an animation that hides the widget(s).

    I am trying to figure out how to have two subsequent events be captured and handled in the simplest, most efficient way. I believe I'd need to use a combination of QEvent::MouseButtonRelease with QEvent::Leave but

    I'm just not sure how to synchronize both since each event will be received at its own time in my event filter. So for the second event QEvent::MouseButtonRelease, how can we know when that event is handled that a previous event QEvent::Leave

    has just occured to get the desired behaviour?

    I am also open to any other methods that are more ideal to solving this problem.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QEvent::MouseButtonRelease with QEvent::Leave

    If the mouse hovers away from the widget, and then a mouse click occurs anywhere outside the widget , then I have an animation that hides the widget(s).
    This description is not very clear as it leaves open questions:
    Hovering over widgets is something you generally do when the mouse moves on the screen.
    So chances are that a situation where the mouse has hovered away from a widget it usually present - unless your application window opened not under the mouse pointer, and you have not yet moved the mouse over your application window.
    This in turn means that usually any click will mean hiding the widgets.
    More over, what if you hover over one widgets, leave it, hover over another widget and leave that as well, and then click somewhere.
    Should both hovered and left widgets be hidden?

    For the sake of simplicity I will assume that the answer is yes, that for each hovered and left widget when an "external" click occurs they all should be hidden.
    One way to implement it would be to "register" each widget which gets a leave event (say, add its pointer to a list) and then in the mouse release event simply go over that list and call hide() on the elements in that list (and then empty the list).
    More details on your part might change that answer however.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    qtstarter121 (1st August 2017)

Similar Threads

  1. QEvent::ApplicationDeactivate
    By migel in forum Newbie
    Replies: 1
    Last Post: 23rd April 2012, 07:54
  2. how to use qevent?
    By cic in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2011, 09:30
  3. How do I use QEvent?
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2011, 10:37
  4. QEvent problem
    By batileon in forum Qt Programming
    Replies: 3
    Last Post: 4th May 2009, 12:23
  5. QEvent::Enter
    By incapacitant in forum Newbie
    Replies: 6
    Last Post: 22nd March 2006, 08:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.