Results 1 to 5 of 5

Thread: Tooltips which follow the mouse

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation Tooltips which follow the mouse

    Hi,
    Is it possible to have the tooltips which follow the mouse ?
    The question is about tooltips of QMenu and QTreeWidgetItem but if a generic method works for all it's better.
    How achieve that if it's possible ?
    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Tooltips which follow the mouse

    QToolTip is just a QWidget. You can create one and show() or hide() it any time and anywhere you want. They are normally used in connection with some other widget, to give a hint about what a particular GUI item or command does.

    So if you display one somewhere off in space, not in association with anything but just following the mouse around, how is that going to help the user?

  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tooltips which follow the mouse

    It's just to change it to be dynamic and not static when the cursor is on a menu for example.
    The only way is to inherit QMenu and manage to show a QTooltip manually ?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Tooltips which follow the mouse

    The default behavior is to show the tooltip after a slight delay if the mouse is not moving, and to hide it after a certain period of time or if the mouse moves. In Qt 5.2+ you can set the tool tip duration, but it will still hide if the mouse moves.

    If you don't like this behavior, then you do not have to inherit QMenu. You can install an event filter on your menu instance and respond to the QEvent types Enter, Leave, MouseMove, and MouseButtonPress. For Enter, you should start a single-shot QTimer and wait until it fires, then show your own QToolTip. For Leave, you hide the tool tip if it is visible. For MouseMove, you need to move the tool tip. For MouseButtonPress you need to hide it as well. In any case, you need to disable the menu's normal tool tip handling.

    Seems like a lot of work for something which will quickly become very annoying to users. What if you used an application like this, and there was no way for you to get the *%&# tool tip to go away? It's stuck to the mouse, no matter how hard you shake it. In every other application you use, moving the mouse makes it go away, but not this one. Time to file a bug report.

  5. #5
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tooltips which follow the mouse

    Quote Originally Posted by d_stranz View Post
    The default behavior is to show the tooltip after a slight delay if the mouse is not moving, and to hide it after a certain period of time or if the mouse moves. In Qt 5.2+ you can set the tool tip duration, but it will still hide if the mouse moves.
    I don't have this behavior using Qt 5.5.0, after a delay the tooltip is shown, doesn't move and is not hidden until the mouse is out of the widget.
    If the qtooltip follows the cursor it end to the same behavior but the tooltip moves.

Similar Threads

  1. How to follow a a href hyperlink?
    By ddz91 in forum Qt Webkit
    Replies: 0
    Last Post: 18th September 2013, 19:46
  2. Have translucent window follow mouse
    By mike_am_i in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2009, 11:18
  3. QGraphicsView to follow Item?
    By sven-kt in forum Qt Programming
    Replies: 5
    Last Post: 25th August 2009, 09:40
  4. How to follow a link in QWebKit?
    By piotr.dobrogost in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2009, 15:05
  5. How can I follow the mouse?
    By T.I.M in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2009, 09:42

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.