PDA

View Full Version : QToolButton Leave Event on Mouse Leave QToolButton



neohaider
14th April 2019, 08:06
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.

anda_skoa
14th April 2019, 10:47
Have you enabled mouse tracking on the buttons?

Cheers,
_

neohaider
16th April 2019, 05:19
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

anda_skoa
16th April 2019, 09:02
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,
_

neohaider
16th April 2019, 09:42
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.

anda_skoa
16th April 2019, 18:47
You could try adding Leave tracking to the menu.

Cheers,
_

neohaider
29th April 2019, 06:04
You could try adding Leave tracking to the menu.

Cheers,
_

Not getting any leave tracking of the menu.