QSystemTrayIcon does not seem.

  • Hi; I am using QSystemTrayIcon but icon does not seem. My code:

    QSystemTrayIcon* tray_icon = new QSystemTrayIcon;
    tray_icon->setToolTip("Hello World!");
    tray_icon->showMessage(tr("Message Title"), tr("Hello Everbody!"), QSystemTrayIcon::Critical);


  • @Ibrahim said:

    first thing to do:
    "check whether a system tray is present on the user's desktop, call the QSystemTrayIcon::isSystemTrayAvailable() static function."

    if check did not fail mostly likely button is there you just see no icon cause you did not set any.

    #include <QSystemTrayIcon>
    #include <QIcon>
    #include <QDebug>
    #include <QApplication>

    QSystemTrayIcon* tray_icon = new QSystemTrayIcon (this );
    tray_icon->setToolTip("Hello World!");

    QIcon icon = QApplication::style()->standardIcon( QStyle::SP_ComputerIcon ) ;
    Q_ASSERT( !icon.isNull() );
    tray_icon->setIcon( icon );
    tray_icon->showMessage(tr("Message Title"), tr("Hello Everbody!"), QSystemTrayIcon::Critical );

  • @alex_malyu thanks. Can I use that in mobile applications (like notification)?

  • @alex_malyu said:


    I have no experience, I think if QSystemTrayIcon::isSystemTrayAvailable() returns there true you can, otherwise you can't.

Log in to reply

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