How to know if I'm showing a tooltip?

John Tapsell johnflux at
Fri Mar 18 11:24:05 GMT 2011

Hi all,

  When the user hovers over an item, it shows a tooltip.  I update
that tooltip once a second using the following code:

        if(QToolTip::isVisible()) {
            QWidget *w = d->mUi->treeView->viewport();
QCursor::pos() ))) {
                QHelpEvent event(QEvent::ToolTip, w->mapFromGlobal(
QCursor::pos() ), QCursor::pos());
                qApp->notify(w, &event);

This works, but the trouble is is that the tooltip could be visible
due to a dialog window.  So if I open a dialog box, then hover over an
item in that dialog box, it shows the correct tooltip for a moment,
then changes to the tooltip for the main window underneath, due to
that code I pasted above.

I've tried  && window()->isActiveWindow()  which partially solves the
problem, but it's possible to have a dialog box on top, but have the
main window have the focus..

Any ideas?


More information about the kde-core-devel mailing list