PDA

View Full Version : Tooltip delays



drhex
19th August 2007, 11:12
Hi,

Some of my widgets show a little more than usual in their tooltip and so the user might need a few extra seconds to read it. How can the delay-until-tooltip-disappears be controlled?

I've looked for:
* extra time-arguments to setTooltip()
* global control-methods in QApplication (where you can set doubleclick interval, cursor flash time and other related stuff)
* methods on QStyle classes
* methods on QToolTip

...but found nothing to help me so far.

marcel
19th August 2007, 11:27
You can override QWidget::event for your widget and intercept QEvent::ToolTip.
When you get it, show a tooltip and also start a single shot timer. When it timeouts, in the slot connected to its timeout signal ,call QToolTip::hideText and hide the tooltip.

Regards

drhex
19th August 2007, 13:54
It seems Qt starts a timer when QToolTip::showText() is called, which kills the tip after 10 seconds, so it does not help if I start my own timer with a longer delay: the tip is already dead when my timer fires.

Is there a way to stop Qt's own tip-killing timer?
Or should I let my timer call showText() again every 10 seconds? (which seems rather silly and I wouldn't know when to stop calling showText, and the "10 seconds" would be a magic number that might be different in the future...)

marcel
19th August 2007, 19:44
That's true.
I think a good solution to do this is to extract QToolTip from the Qt sources, rename it, add a few extra methods for timer control and use it.

It is a very small class, so it shouldn't have a big impact when you switch to a newer Qt version.

You'll have to get a little into the QTipLabel class, implemented in QToolTip.cpp. It provides all the tooltip functionality.

Regards

drhex
19th August 2007, 21:38
Ok, if I copy-paste the entire QTipLabel class into a MyTipLabel class and fiddle with restartHideTimer(), and roll my own QToolTip::showText() which uses the new class
I suppose I could get it to work, but it seems too deperate. I'd miss out on any future
improvement to QTipLabel. Since that class is not exposed in the normal API,
the trolls will not hesitate to modify it.

I guess I'll have to put up with the short-lived tooltip for now and send a suggestion to the Trolls for a more flexible future version.

marcel
19th August 2007, 21:52
I guess I'll have to put up with the short-lived tooltip for now and send a suggestion to the Trolls for a more flexible future version.

Of course, you can do that. It would be better if they add something to support this in the API.



Ok, if I copy-paste the entire QTipLabel class into a MyTipLabel class and fiddle with restartHideTimer()

I think you can add a member that tells the tooltip the duration you want for it.

Regards

drhex
20th August 2007, 20:19
The suggestion has been received by the trolls:

http://trolltech.com/developer/task-tracker/index_html?id=175687&method=entry

TheRonin
6th February 2009, 14:10
Unfortunately, the requested functionality has yet to be implemented. :/

dfaure
15th November 2011, 22:46
After the change of bug tracker, the request for Qt is now at https://bugreports.qt.nokia.com/browse/QTBUG-1016