简体   繁体   English

如何使用 C++ 在 Linux 中制作托盘图标?

[英]How can i make a tray icon in Linux using C++?

In Windows, I can use Shell_NotifyIcon() .在 Windows 中,我可以使用Shell_NotifyIcon() What is the Linux equivalent of this function?这个函数的 Linux 等价物是什么?

Is it different in GNOME (gtk) and KDE (qt)? GNOME (gtk) 和 KDE (qt) 有什么不同? Can't find any tutorials on the Internet.在互联网上找不到任何教程。

Yes, it depends on a desktop environment you're using.是的,这取决于您使用的桌面环境。

In Qt (KDE), you can do this in a cross-platform manner using QSystemTrayIcon .在 Qt (KDE) 中,您可以使用QSystemTrayIcon以跨平台方式执行此QSystemTrayIcon

There is even a sample application in Qt . Qt 中甚至还有一个示例应用程序

In GTK, you do this with GtkStatusIcon .在 GTK 中,您可以使用GtkStatusIcon执行此GtkStatusIcon There is a sample application in this blog post . 这篇博文中有一个示例应用程序。

All major desktop support the current XEmbed based systray icon specification.所有主要桌面都支持当前基于 XEmbed 的系统托盘图标规范。 Qt and GTK both provide facilities to use that protocol in comfortable manner. Qt 和 GTK 都提供了以舒适的方式使用该协议的设施。 Regardless of your toolkit choice the icons will appear on all desktop environments.无论您选择何种工具包,图标都会出现在所有桌面环境中。 If you use Qt you get even compatability with other platforms like Windows for free.如果您使用 Qt,您甚至可以免费与其他平台(如 Windows)兼容。

For Gnome, there's this tutorial and the gtkmm toolkit for C++对于 Gnome,有教程和 C++ 的gtkmm工具包

EDIT: This is for panel applets, you asked for system tray icons.编辑:这是面板小程序,您要求提供系统托盘图标。 They're similar, but not quite the same.它们很相似,但并不完全相同。 Go with Reed 's answer.同意Reed的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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