My Qt application, which calls ffmpeg, is working great on Linux.
It works on OS X as long as I launch it from a Terminal, but not if I launch it from the desktop; so obviously from the GUI launcher it's not inheriting the appropriate environment.
So I'm trying to utilize QProcess systemEnvironment
The Qt docs gives this Windows-ian example:
env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
env.
replaceInStrings(QRegExp("^PATH=(.*)", Qt
::CaseInsensitive),
"PATH=\\1;C:\\Bin");
process.setEnvironment(env);
process.start("myapp");
QProcess process;
QStringList env = QProcess::systemEnvironment();
env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;C:\\Bin");
process.setEnvironment(env);
process.start("myapp");
To copy to clipboard, switch view to plain text mode
Which I assume I would adapt like this:
void startProcess()
{
env << ":/usr/local/bin"; // Add the bin dir to PATH
process.setEnvironment(env);
process.start("????");
void startProcess()
{
QProcess process;
QStringList env = QProcess::systemEnvironment();
env << ":/usr/local/bin"; // Add the bin dir to PATH
process.setEnvironment(env);
process.start("????");
To copy to clipboard, switch view to plain text mode
My three questions:
1. I am not sure if I am adding /usr/local/bin to PATH or not. I think I am.
2. What exactly am I satarting with process.start ? main? mainwindow.cpp ? what is it asking for here?
3. Also, am I right to be placing that block of code in main.cpp above int main or is there a better place for it.
Thanks in advance. Qt is amazing so far!
Bookmarks