Thanks for the ideas, I got it working like this now:
bool myWidget::event(QEvent* e) { if(e->type() == QEvent::Leave) { QPoint view_pos(x(), y()); QPoint view_pos_global = mapToGlobal(view_pos); QPoint mouse_global = QCursor::pos(); if(mouse_global.x() < view_pos_global.x() || mouse_global.x() > view_pos_global.x() + width()) { closeMenu(); } else if(mouse_global.y() < view_pos_global.y() || mouse_global.y() > view_pos_global.y() + height()) { closeMenu(); } } return QWidget::event(e); }