Results 1 to 7 of 7

Thread: QToolButton Leave Event on Mouse Leave QToolButton

  1. #1
    Join Date
    Apr 2019
    Location
    Islamabad
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default QToolButton Leave Event on Mouse Leave QToolButton

    Hi
    I have multiple qtoolbutton in a class inherited from qwidget. when mouse is move on that they show their respective menu. i have implemented eventfilters. my code work fine in QT4 but not works fine in QT5. Onclick it works fine but not on mouse move. as per documented i set MouseTracking on.

    Code:

    class myClass: public QWidget
    {
    setMouseTracking(TRUE);
    ........ 8 QToolButtons
    QToolButton->installEventFilter(this);
    }

    bool myClass::eventFilter(QObject *obj, QEvent *event)
    {
    if(event->type()==QEvent::Enter)
    {
    if(obj == toolbutton1)
    showMenu1()
    // same for all tool button
    return true;
    }
    return QWidget::event(obj,event);
    }

    i printed qDebug it shows leaveEvent not called on mouse move. it just called on Mouse click.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton Leave Event on Mouse Leave QToolButton

    Have you enabled mouse tracking on the buttons?

    Cheers,
    _

  3. #3
    Join Date
    Apr 2019
    Location
    Islamabad
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QToolButton Leave Event on Mouse Leave QToolButton

    Quote Originally Posted by anda_skoa View Post
    Have you enabled mouse tracking on the buttons?

    Cheers,
    _
    Yes I enabled mouse tracking. also i tried to reimplement Leave Event. but achieve nothing. Leave Event only called on Mouse Click. Not work on mouse leave qtoolbutton boundary. it works in QT4. but not in QT5

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton Leave Event on Mouse Leave QToolButton

    Could be related to showing the menu.

    Do you get a leave event if you do not show the menu?

    If so you might need to track enter/leave for the menu

    Cheers,
    _

  5. #5
    Join Date
    Apr 2019
    Location
    Islamabad
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Thumbs up Re: QToolButton Leave Event on Mouse Leave QToolButton

    Quote Originally Posted by anda_skoa View Post
    Could be related to showing the menu.

    Do you get a leave event if you do not show the menu?

    If so you might need to track enter/leave for the menu

    Cheers,
    _
    Yes, without menu it's work fine. leave event called. how its works fine with show/hide menu.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton Leave Event on Mouse Leave QToolButton

    You could try adding Leave tracking to the menu.

    Cheers,
    _

  7. #7
    Join Date
    Apr 2019
    Location
    Islamabad
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QToolButton Leave Event on Mouse Leave QToolButton

    Quote Originally Posted by anda_skoa View Post
    You could try adding Leave tracking to the menu.

    Cheers,
    _
    Not getting any leave tracking of the menu.

Similar Threads

  1. QListWidgetItem Mouse Enter/Leave Event
    By tvj4218 in forum Newbie
    Replies: 1
    Last Post: 5th January 2017, 21:14
  2. Replies: 3
    Last Post: 7th August 2015, 13:37
  3. QGraphicsItem can't receive mouse leave/enter event
    By wshn13 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2011, 09:32
  4. QPushbutton leave event
    By mikec in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2010, 09:38
  5. Mouse Leave and Tab Key event in Delegate
    By faldzip in forum Qt Programming
    Replies: 0
    Last Post: 30th October 2008, 20:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.