带箭头的 Qt 工具提示 [英] Qt tooltip with arrow
问题描述
我有基于 Qt 5.2.1 小部件的项目.当用户悬停一些标签(或任何其他可以显示图像的小部件)时,我想用箭头显示很酷的工具提示,如下所示:
I have Qt 5.2.1 widgets-based project. I want to show cool tooltip with arrow while user hovers some labels (or any other widgets that can show image), like this:
但我没有找到这方面的例子.那么我可以用 QToolTip
做到这一点吗?或者我应该使用其他小部件来达到相同的外观吗?
But i found no examples for this. So am i able to do this with QToolTip
? Or should i use another widgets to reach same look instead?
无论我必须使用什么类和样式,我都需要以任何方式达到类似的效果.
It is no matter what classes and styles i have to use, i need to reach similar effect any way.
我曾尝试使用基本 CSS 自定义 QToolTip
但失败了.
I've tried to customize QToolTip
with basic CSS but had failed.
推荐答案
您可以使用QBalloonTip
,它是
QtDir/5.2.1/Src/qtbase/src/widgets/util/qsystemtrayicon_p.h
QBalloonTip
继承了QWidget
并在同目录的qsystemtrayicon.cpp
中实现.它有以下方法来显示气球提示:
QBalloonTip
inherits QWidget
and it is implemented in qsystemtrayicon.cpp
at the same directory. It has the following method to show a balloon tip:
void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow)
你可以修改这个类的源代码以获得你想要的气球提示.
You can modify the source code of this class to have your desired balloon tip.
这篇关于带箭头的 Qt 工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!