9

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?

Colonel Panic
  • 1,604
  • 2
  • 20
  • 31
Sebastian Negraszus
  • 11,915
  • 7
  • 43
  • 70

3 Answers3

1

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

Nejat
  • 31,784
  • 12
  • 106
  • 138
1

To 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 headers

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

Then call static method showBallon() or instantiate it and call baloon(). 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

1

Search for QBalloonTip class (in Qt documentation (doxygen reference) and code base, look how it is implemented, and use similar technique.

mloskot
  • 37,086
  • 11
  • 109
  • 136
  • 1
    Except that `QBalloonTip` is an internal class defined in `src/gui/utils/util/qsystemtrayicon_p.h` and not part of the public and documented API. – alexisdm Oct 24 '11 at 19:32
  • 3
    Qt 4.7 Assistant does not know this class. A Google search shows this an internal class used by QSystemTrayIcon and not part of the API. Are you sure this is the class I am looking for? – Sebastian Negraszus Oct 24 '11 at 19:33