本文介绍了Qt-如何检测应用程序是否在GNOME或KDE上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我该怎么做()使用Qt.我浏览了文档,但找不到任何方法来检查外部进程是否正在运行.

I was wondering how I could do something like this (source) using Qt. I looked through the documentation but couldn't find any method to check if an external process is running.

if [ "$(pidof ksmserver)" ]; then
   echo "KDE running."
   # KDE-specific stuff here
elif [ "$(pidof gnome-session)" ]; then
   echo "GNOME running."
   # GNOME-specific stuff here
elif [ "$(pidof xfce-mcs-manage)" ]; then
   echo "Xfce running."
   # Xfce-specific stuff here
fi

推荐答案

使用QProcess运行pidof foo,然后检查其stdout?如果这不是您想要的,请搜索/proc/.

Use QProcess to run pidof foo, then check its stdout? If this is not what you want, search /proc/.

这篇关于Qt-如何检测应用程序是否在GNOME或KDE上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 23:05