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

时间:2022-08-26 21:35:48

In Windows, I can use Shell_NotifyIcon(). What is the Linux equivalent of this function?

在Windows中,我可以使用Shell_NotifyIcon()。这个函数的Linux等价物是什么?

Is it different in GNOME (gtk) and KDE (qt)? Can't find any tutorials on the Internet.

GNOME(gtk)和KDE(qt)有什么不同吗?在Internet上找不到任何教程。

3 个解决方案

#1


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以跨平台方式执行此操作。

There is even a sample application in Qt.

Qt中甚至还有一个示例应用程序。

In GTK, you do this with GtkStatusIcon. There is a sample application in this blog post.

在GTK中,您可以使用GtkStatusIcon执行此操作。此博客文章中有一个示例应用程序。

#2


All major desktop support the current XEmbed based systray icon specification. Qt and GTK both provide facilities to use that protocol in comfortable manner. 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.

所有主要桌面都支持当前基于XEmbed的系统托盘图标规范。 Qt和GTK都提供了以舒适的方式使用该协议的工具。无论您的工具包选择如何,图标都将显示在所有桌面环境中。如果您使用Qt,您甚至可以免费与其他平台(如Windows)兼容。

#3


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.

编辑:这是面板小程序,您要求系统托盘图标。它们相似,但不完全相同。跟着里德的回答一起去吧。

#1


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以跨平台方式执行此操作。

There is even a sample application in Qt.

Qt中甚至还有一个示例应用程序。

In GTK, you do this with GtkStatusIcon. There is a sample application in this blog post.

在GTK中,您可以使用GtkStatusIcon执行此操作。此博客文章中有一个示例应用程序。

#2


All major desktop support the current XEmbed based systray icon specification. Qt and GTK both provide facilities to use that protocol in comfortable manner. 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.

所有主要桌面都支持当前基于XEmbed的系统托盘图标规范。 Qt和GTK都提供了以舒适的方式使用该协议的工具。无论您的工具包选择如何,图标都将显示在所有桌面环境中。如果您使用Qt,您甚至可以免费与其他平台(如Windows)兼容。

#3


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.

编辑:这是面板小程序,您要求系统托盘图标。它们相似,但不完全相同。跟着里德的回答一起去吧。