问题
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:
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 callQToolTip::showText()instead ofsetToolTip()in your implementation ofmouseMoveEvent().
But instead of using the mouseMoveEvent, you could also use the QWidget::enterEvent(QEvent*).
来源:https://stackoverflow.com/questions/13720465/how-to-remove-the-time-delay-before-a-qtooltip-is-displayed