Results 1 to 9 of 9

Thread: Tooltip delays

  1. #1
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Tooltip delays

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip delays

    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

  3. #3
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Tooltip delays

    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...)

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip delays

    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

  5. The following user says thank you to marcel for this useful post:

    drhex (19th August 2007)

  6. #5
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Tooltip delays

    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.

  7. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip delays

    Quote Originally Posted by drhex View Post
    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

  8. #7
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Tooltip delays

    The suggestion has been received by the trolls:

    http://trolltech.com/developer/task-...7&method=entry

  9. The following user says thank you to drhex for this useful post:

    TheRonin (6th February 2009)

  10. #8
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip delays

    Unfortunately, the requested functionality has yet to be implemented. :/

  11. #9
    Join Date
    Jan 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tooltip delays

    After the change of bug tracker, the request for Qt is now at https://bugreports.qt.nokia.com/browse/QTBUG-1016

Similar Threads

  1. ToolTip....
    By merry in forum Qt Programming
    Replies: 27
    Last Post: 3rd August 2007, 10:42
  2. Tooltip on item in tableview
    By steg90 in forum Qt Programming
    Replies: 22
    Last Post: 17th May 2007, 11:03
  3. Delays in processing events
    By Caius Aérobus in forum Qt Programming
    Replies: 6
    Last Post: 7th April 2006, 12:42
  4. Moving Tooltip out of cursor-area
    By afo in forum KDE Forum
    Replies: 1
    Last Post: 7th January 2006, 15:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.