如何在显示 QToolTip 之前消除时间延迟? [英] How to remove the time delay before a QToolTip is displayed?

查看:52
本文介绍了如何在显示 QToolTip 之前消除时间延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 QToolTip 的自定义 QGraphicsItem.将鼠标悬停在其上时,工具提示显示正常,但在工具提示显示之前有一小段延迟.

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?

推荐答案

QWidget::mouseMoveEvent(QMouseEvent*) 可以阅读以下说明:

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

如果您想在鼠标移动时立即显示工具提示(例如,使用 QMouseEvent::pos() 获取鼠标坐标并显示它们作为工具提示),您必须首先按照描述启用鼠标跟踪以上.然后,为确保工具提示立即更新,您必须调用 QToolTip::showText() 而不是 setToolTip() 在你的mouseMoveEvent() 的实现.

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

但是除了使用 mouseMoveEvent,您还可以使用 QWidget::enterEvent(QEvent*).

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

这篇关于如何在显示 QToolTip 之前消除时间延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆