简体   繁体   中英

Possible to set taskbar (system tray) icon for Qt console app?

Please consider, this is explicitly asking about an console application.

I know how to set the application icon, which is not the taskbar icon:

  1. Qt Setting the Application Icon
  2. https://stackoverflow.com/a/1460372/356726

For a Qt Widget application, I can set the icon in Qt Creator ( windowIcon ) or use setWindowIcon(QIcon(":/the_icon.ico")); ( see here )

But is there a way to set the icon for a Qt console application ?

You need to include the widgets module in spite of only using a console interface. Then you can use the QSystemTrayIcon class. It works fine whether it's a console application or not.

If you do not wish to use the QSystemTrayIcon class, then you have to resort to using winapi.

Remember that the only difference between a "console" application and non-console one on Windows is a flag set in the executable's header. There's no other fundamental difference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM