Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.7.2
-
None
Description
If a tooltip is shown via an action in a menu then it gets hidden when the menu closes even if the tooltip is not associated with the menu widget.
The example below reproduces the problem. Even though the tooltip is set for the visible mainwindow, the tooltip closes when a leaveevent is sent for the menu.
#include <QtGui> class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow() { setCentralWidget(new QTextEdit(this)); QMenu *menu = menuBar()->addMenu("Test"); QAction *testAction = new QAction(this); testAction->setText("Click Me"); menu->addAction(testAction); connect(testAction, SIGNAL(triggered()), this, SLOT(test1())); } public slots: void test1() { QToolTip::showText(QPoint(100,200),"Leaving",this); } }; #include "main.moc" int main(int argc, char** argv) { QApplication app(argc, argv); MainWindow window; window.show(); return app.exec(); }
The following patch fixes the bug:
--- a/src/gui/kernel/qtooltip.cpp +++ b/src/gui/kernel/qtooltip.cpp @@ -318,7 +318,8 @@ bool QTipLabel::eventFilter(QObject *o, QEvent *e) } #endif case QEvent::Leave: - hideTip(); + if (o == widget) + hideTip(); break; case QEvent::WindowActivate: case QEvent::WindowDeactivate: