在Mac上启动没有停靠图标的Qt托盘过程 [英] Start a Qt tray process without dock icon on Mac

查看:439
本文介绍了在Mac上启动没有停靠图标的Qt托盘过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含GUI,服务和托盘的包装.请注意,这是三个独立的过程.

I have a bundle with a GUI, service and tray. Note they are three separate processes.

这听起来很奇怪,托盘代表了服务,用户可以打开GUI,如果没有退出,它将创建一个托盘.

It may sound weird, the tray is a representation of the service and users can open the GUI which would create a tray if none exits.

所以在我的GUI代码中,我有如下内容:

So in my GUI code I have something like below:

QProcess::startDetached("my-tray");

由于GUI是主要可执行文件,因此整个捆绑软件都已配置.

The whole bundle is configured as the GUI is the main executable.

问题是:当GUI启动任务栏时,我可以在扩展坞中看到两个图标.我想要的是启动托盘,而坞站中没有任何其他图标.

THE PROBLEM IS: when the GUI starts a tray, I can see two icons in dock. What I want is starting the tray without any extra icon in dock.

我尝试按照建议的此处将QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM设置为true.

I have tried to set QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM to true as suggested here.

我已尝试按照建议的我认为在plist文件中将LSUIElement设置为1并不是对我有效的解决方案,因为我仍然希望GUI在扩展坞中显示图标.

I don't think set LSUIElement to 1 in plist file is a valid solution for me, because I still want the GUI show an icon in dock.

当前,我将所有进程都放在软件包的MacOS文件夹中.将托盘移到Resources文件夹中导致无法加载某些可可库.

Currently, I put all processes in the MacOS folder within the bundle. Moving tray into Resources folder caused it failed to load some cocoa library.

此应用程序无法启动,因为无法找到或加载该应用程序 Qt平台插件"cocoa"位于"中.

This application failed to start because it could not find or load the Qt platform plugin "cocoa" in "".

整个项目是一个用C ++编写的Qt项目.托盘过程本质上是一个QSystemTrayIcon.

The whole project is a Qt project written in C++. The tray process is essentially a QSystemTrayIcon.

推荐答案

问题是:当GUI启动任务栏时,我可以在扩展坞中看到两个图标.

THE PROBLEM IS: when the GUI starts a tray, I can see two icons in dock.

一种可能的解决方案是使托盘"处理自己的应用程序捆绑包(并仍放在主应用程序的捆绑包中)并进行设置

One possible solution would be to make the "tray" process its own application bundle (and still putting within the bundle of the main application) and setting

<key>NSUIElement</key>
<string>1</string>

在纸盒包装的Info.plist中.

这篇关于在Mac上启动没有停靠图标的Qt托盘过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆