24

I have a custom QGraphicsItem with a QToolTip. When hovering with the mouse on them the tool tip shows fine, but there is a small delay before the tool tip shows.

How can I decrease that delay, so the tool tip will show immediately?

1 Answer 1

23

In the documentation for QWidget::mouseMoveEvent(QMouseEvent*) you can read the following description:

If you want to show a tooltip immediately, while the mouse is moving (e.g., to get the mouse coordinates with QMouseEvent::pos() and show them as a tooltip), you must first enable mouse tracking as described above. Then, to ensure that the tooltip is updated immediately, you must call QToolTip::showText() instead of setToolTip() in your implementation of mouseMoveEvent().

But instead of using the mouseMoveEvent, you could also use the QWidget::enterEvent(QEvent*).

3
  • 1
    I used the first option you gave, it's worked great, thanks a lots.
    – GoldenAxe
    Commented Dec 5, 2012 at 17:02
  • If an event filter is already installed on the target object, QEvent::HoverMove type would suit this scenario best. Unlike QEvent::MouseMove, there is no need to enable mouse tracking on the object for it to work. I also noticed that using this event introduces much less annoying tooltip drawing stutter (I don't know where it comes from).
    – Jacek C.
    Commented Nov 7, 2019 at 17:26
  • How about the other way around, delaying a tooltip to be distractive right away? Commented May 18, 2022 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.