How to set Alerts in MAC system



  • Hi,

    Mac has Banners, Alerts, and Badges (https://support.apple.com/en-il/HT204079)
    How can I use this tool from the QT?

    Thx


  • Moderators

    @borisa
    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

    Hi,

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.