简体   繁体   English

如何在Qt中打开和最小化外部应用程序到系统托盘

[英]How to open and minimize external app to system tray in Qt

QProcess can be used to open external program, but it will always open an app to the front of all other windows. QProcess可以用来打开外部程序,但是它将始终在所有其他窗口的前面打开一个应用程序。

Is there a way to open an external app and then minimize/hide this opened app to the system tray? 有没有办法打开一个外部应用程序,然后最小化/隐藏这个打开的应用程序到系统托盘?

QString path = QString("external app path here").replace("/", "\\");

QProcess process;
process.start(path); //open the external app, but it will stay on top of other windows 
if (process.isOpen()) {
    //then minimize this app to system tray;
}

Is this( open and minimize external app to system tray ) achievable using Qt methods? 使用Qt方法可以open and minimize external app to system tray这一点( open and minimize external app to system tray )吗?

If Qt has no way to minimize opened external app to system tray. 如果Qt无法将打开的外部应用程序最小化到系统托盘中。 Do I have to use Windows API? 我必须使用Windows API吗? Any advice or example code would be appreciated. 任何建议或示例代码将不胜感激。

This should not be specific to Qt. 这不应该特定于Qt。 Perhaps Qt session management could be relevant. 也许Qt会话管理可能是相关的。

It is a matter of window manager and of desktop environment . 这是窗口管理器桌面环境的问题 Both are provided by (very broadly speaking) your "operating system" and are not tied to one particular process using Qt. 两者都是(从广义上来说)由您的“操作系统”提供的,并且与使用Qt的特定过程无关。

The system tray belongs to the desktop environment. 系统托盘属于桌面环境。 A particular process using Qt has no reason to minimize it. 使用Qt的特定过程没有理由将其最小化。 The minimization of the system tray is the business of the desktop environment (not of one particular Qt application). 系统托盘的最小化是桌面环境(而不是一个特定的Qt应用程序)的问题。 I see no reason why your application would do that (remember that your user could also run other applications, which are even more important to him than yours and which also interact with or require using the system tray). 我看不出您的应用程序会这样做的原因(请记住,您的用户还可以运行其他应用程序,这些应用程序对他来说比您的应用程序更重要,并且还需要与系统托盘进行交互或需要使用系统托盘)。

Of course, Qt provides an API to interact with the window manager and the desktop environment. 当然,Qt提供了与窗口管理器和桌面环境进行交互的API。

PS. PS。 On Linux, the convention between a Qt application and the window manager or desktop environment are documented in EWMH and ICCCM. 在Linux上,EWMH和ICCCM中记录了Qt应用程序与窗口管理器或桌面环境之间的约定。 You need to find the equivalent for Windows. 您需要找到Windows的等效文件。 I never used Windows so I don't know them. 我从未使用过Windows,所以我不认识它们。 On Linux, one can code a window manager using Qt. 在Linux上,可以使用Qt编写一个窗口管理器。

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

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