Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18520

Tooltips are hidden immediately after being shown

    XMLWordPrintable

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:
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            naevdal Sigrid Fjell Nævdal (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes