使用 Qt 实现气球提示
在我的 Qt 应用程序中,我想使用气球/气球提示,如 Windows 用户体验指南(不是系统托盘气球)。
Qt 支持吗?我还没找到任何东西。有没有可用的开源库(Qxt 没有)?自己创建它的最佳方法是什么?
In my Qt application, I'd like to use balloons/balloon-tips as shown in the Windows user experience guide (not the system tray balloons).
Is this supported by Qt? I haven't found anything. Is there an Open Source library out there for this (Qxt does not have it)? What's the best way to create that myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
搜索 QBalloonTip 类(在 Qt 文档(doxygen 参考)和代码库中,查看它是如何实现的,并使用类似的技术。
Search for
QBalloonTip
class (in Qt documentation (doxygen reference) and code base, look how it is implemented, and use similar technique.您可以使用
QBalloonTip
,它是在以下位置定义的内部类:Qt 5:
QtDir/Src/qtbase/src/widgets/util/qsystemtrayicon_p.h
Qt 4:
QtDir/src/gui/utils/util/qsystemtrayicon_p.h
QBalloonTip
继承了QWidget
,并在同一目录下的qsystemtrayicon.cpp
中实现。它有以下方法来显示气球提示:您可以修改该类的源代码以获得您想要的气球提示。
You can use
QBalloonTip
which is an internal class defined in :Qt 5:
QtDir/Src/qtbase/src/widgets/util/qsystemtrayicon_p.h
Qt 4:
QtDir/src/gui/utils/util/qsystemtrayicon_p.h
QBalloonTip
inheritsQWidget
and it is implemented inqsystemtrayicon.cpp
at the same directory. It has the following method to show a balloon tip:You can modify the source code of this class to have your desired balloon tip.
要在 Qt 5.12 中使用私有类
QBaloonTip
,您需要执行以下操作:1) 将
QT += widgets-private
添加到您的 PRO 文件中,以便能够包含私有标头2 )
#include
在源文件中然后调用静态方法
showBallon()
或实例化它并调用 baloon() 。但它实际上仅适用于系统托盘,并且是私有 API,可以随时更改。我个人不会使用它。但如果您想知道它是如何呈现的,请查看 https://code.woboq.org/qt5/qtbase/src/widgets/util/qsystemtrayicon.cpp.html#_ZN11QBalloonTip10paintEventEP11QPaintEventTo use private class
QBaloonTip
in Qt 5.12 you need to do the following:1) add
QT += widgets-private
to your PRO file to be able to include private headers2)
#include <QtWidgets/private/qsystemtrayicon_p.h>
in your source fileThen call static method
showBallon()
or instantiate it and callbaloon()
. But it is really only for system tray and it is a private API, which can change any time. I personally would not use it. But if you want to know how it is rendered, have a look at https://code.woboq.org/qt5/qtbase/src/widgets/util/qsystemtrayicon.cpp.html#_ZN11QBalloonTip10paintEventEP11QPaintEvent