In my C++/Qt program I would like to know which text editor is available on user's Linux machine so that I can use it to open a text file from my program. There are several widely used editors such as gedit
, kate
and a few more so I would like to check these. My naive intention was to use QProcess
in combinations with command -v foobar
as in How to check if a program exists from a Bash script? but unfortunately this does not seem to be doing what I expect. I hoped that the exit codes could indicate the result.
qDebug() << QProcess::execute("command -v kate") << QProcess::execute("command -v gedit");
... but the processes did not even started and the line returned -2 -2
.
Is there any way to achieve what I need?