'morning,
I have a custom QWidget, myWid, that pops up when the user mouses over a QPushButton. The QWidget pops-up adjacent to (slightly overlapping) this pushButton. I want myWid to remain shown (popped up) as long as the mouse is over either the QPushButton *or* myWid. My eventFilter looks like this:
{
if(event
->type
() == QEvent::Enter) {
if(obj == myPB)
{
myWid->show();
return QWidget::eventFilter(obj, event
);
}
return QWidget::eventFilter(obj, event
);
else if(event
->type
() == QEvent::Leave) {
if(obj == myPB)
{
if(!myWid->underMouse())
{
myWid->hide();
return QWidget::eventFilter(obj, event
);
}
return QWidget::eventFilter(obj, event
);
}
return QWidget::eventFilter(obj, event
);
}
return QWidget::eventFilter(obj, event
);
}
bool Window::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter)
{
if(obj == myPB)
{
myWid->show();
return QWidget::eventFilter(obj, event);
}
return QWidget::eventFilter(obj, event);
else if(event->type() == QEvent::Leave)
{
if(obj == myPB)
{
if(!myWid->underMouse())
{
myWid->hide();
return QWidget::eventFilter(obj, event);
}
return QWidget::eventFilter(obj, event);
}
return QWidget::eventFilter(obj, event);
}
return QWidget::eventFilter(obj, event);
}
To copy to clipboard, switch view to plain text mode
the "hide()" above is conditional: if the mouse is over myWid, do not hide() it when Leave myPB. This doesn't work: the panel flickers on/off rapidly or closes when I mouse over it. I understand why this is happening, but I can't figure out an alternative. Suggestions?
Bookmarks