Make a application that create a QSystemTrayIcon and no taskbar entry



  • @#include <QWidget>
    #include <QApplication>
    #include <QSystemTrayIcon>

    int main(int argc, char** argv)
    {
    QApplication app(argc, argv);
    QWidget w1;
    QSystemTrayIcon icon(QIcon("./icon.png"), &w1);
    icon.show();
    app.setQuitOnLastWindowClosed(false);
    return app.exec();
    }@

    When I run this code, sometimes it make no taskbar entry but sometimes it does
    Can anyone explain me why?
    And how can I make a application that only make a systemtray icon without taskbar entry?
    I am using Linux Mint with MATE
    Sorry for my bad english!



  • @
    #include <QApplication>
    #include <QSystemTrayIcon>

    int main(int argc, char** argv)
    {
    QApplication app(argc, argv);

    QSystemTrayIcon icon(QIcon("./icon.png"));
    icon.show();
    
    return app.exec&#40;&#41;;
    

    }
    @



  • [quote author="8majkel8" date="1371136224"]@
    #include <QApplication>
    #include <QSystemTrayIcon>

    int main(int argc, char** argv)
    {
    QApplication app(argc, argv);

    QSystemTrayIcon icon(QIcon("./icon.png"));
    icon.show();
    
    return app.exec(&#41;;
    

    }
    @[/quote]

    It doesn't work. Sometimes it make a taskbar entry.
    This taskbar entry remain even after i have killed this program



  • It's common for all taskabar applications that was not quit but terminated.
    You have to add some custom menu etc. with exit action. Calling QCoreApplication::quit() might be enough.



  • I have tried some code that i found in internet. All of them work corectly in Windows7 but not in LinuxMint with MATE.
    Are there somethings incompatible?
    I use Qt 5.0.2





  • Perhaps the problem is Linux Mint, and not Qt? Perhaps Linux Mint always creates a task-bar entry by default, whether it is requested by the application or not?



  • I use Debian 7 instead of Linux Mint. With Qt 4.8.4 all works well.


Log in to reply
 

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