Swivel tips with Qt

In my Qt application, I would like to use balloons / tooltips, as shown in the User Guide for Windows users (and not the system tray).

Is this supported by Qt? I did not find anything. Is there an open source library (Qxt doesn't have one)? What is the best way to create it yourself?

+7
source share
3 answers

You can use QBalloonTip , which is an inner 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 inherits QWidget and is implemented in qsystemtrayicon.cpp in the same directory. It has the following method to show the tip of the cylinder:

 void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow) 

You can modify the source code of this class to have the desired ball tip.

0
source

To use the QBaloonTip private class in Qt 5.12, you need to do the following:

1) add QT += widgets-private in your PRO file to be able to include private headers

2) #include <QtWidgets/private/qsystemtrayicon_p.h> in your source file

Then call the static method showBallon() or showBallon() its instance and call baloon() . But this is only valid for the system tray, and it is a private API that can change at any time. I personally would not use this. But if you want to know how it is displayed, take a look at https://code.woboq.org/qt5/qtbase/src/widgets/util/qsystemtrayicon.cpp.html#_ZN11QBalloonTip10paintEventEP11QPaintEvent

0
source

Find the QBalloonTip class (in the Qt documentation (link to oxygen) and the code base, see how it is implemented, and use a similar technique.

-one
source

All Articles