I want to be able to show ToolTips for QMenu items (QActions). The best I have achieved is to connect the hovered signal of the QAction to a QTooltip show:
connect(action, &QAction::hovered, [=]{
QToolTip::showText(QCursor::pos(), text, this);
});
The problem is that sometimes the program will position the tooltip below the menu, specially when changing menus.
Is there any way to force the tooltip to show on top?
You can subclass
QMenuand reimplementingQMenu::event()to intercept theQEvent::ToolTipevent and callQToolTip::showTextto set the tooltip for the active action :Now you can use your custom menu like :