Nominate our 2022 Qt Champions!

How to set Alerts in MAC system

  • Hi,

    Mac has Banners, Alerts, and Badges (
    How can I use this tool from the QT?


  • Moderators

    not directly, but it can be easily mimed (platform independently) with QWidgets:

    QFrame* notifier = new QFrame;
    notifier ->setWindowFlags( Qt::Tool | Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint );
    notifier ->setFocusPolicy( Qt::NoFocus );
    const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); // Qt5 way; for Qt4 use QDesktopWidget::availableGeometry(notifier);
    QRect geom = notifier ->geometry();
    geom.moveBottomRight( availableGeometry.bottomRight() - QPoint(20,20) );
    notifier ->setGeometry( geom  );
    notifier ->show();

    For a nicer effect you can additionally use QGraphicsOpacityEffect to fade the widget in and out.

  • Lifetime Qt Champion


    IIRC messages can be sent using QSystemTrayIcon

    Badges can be set using QtMac::setBadgeLabelText

    I don't remember if there's something for the banner however you can use Objective-C++ for that without any problem.

  • Can i included in my project only the relevant h and cpp files (like System.Classes.hpp, FMX.Controls.hpp, FMX.Forms.hpp ....)?
    If so, where can i found them?
    If not, How can i include the Objective-C++ in my QT?

  • Lifetime Qt Champion

    What relevant header file do you mean ?

    Take a look e.g. at the QtMacExtras module there are several examples there.

Log in to reply