22

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?

Andreas Haferburg
  • 5,189
  • 3
  • 37
  • 63
GoldenAxe
  • 838
  • 3
  • 9
  • 26

1 Answers1

22

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

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
mfreiholz
  • 697
  • 1
  • 7
  • 14
  • 1
    I used the first option you gave, it's worked great, thanks a lots. – GoldenAxe Dec 05 '12 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. Nov 07 '19 at 17:26
  • How about the other way around, delaying a tooltip to be distractive right away? – László Papp May 18 '22 at 16:14