Search code examples
c++notificationsqt5system-traykde-plasma

Linux KDE system notification c++/Qt


I'm developing app (plasmoid) for KDE Plasma 5 with c++ and QT. What is simple way to emit system notification (notification in corner of screen like a notification for new email or disconnection from network)? I can do it from terminal by calling 'kdialog ...' but I don't know how to do it from c++ code and yeah I don't want to do 'system(kdialog ...)'. Thanks.


Solution

  • I found the solution:

    QSystemTrayIcon* ic = new QSystemTrayIcon(this);
    ic->setVisible(true);
    ic->showMessage(tr("Notify"), tr("Text"), QSystemTrayIcon::Information, 1000);
    qApp->processEvents();