I’m a student programmer using Qt and I seem to have ran into an issue using QProcess to launch the bash command ‘which’ in an attempt to collect a map of installations of an application. I have the following code and I’m truly lost as to what I might be missing. I have referenced the QProcess documentation and still cant figure out whats wrong.
Every time this code is ran the file is not created in the indicated directory. Without the file constructed the application cannot proceed.
//datatypes
QProcess *findFiles = new QProcess();
QStringList arguments;
QStringList InstallationList;
QString program = "/bin/bash";
QString currentUsersHomeDirectory = QDir::homePath();
QString tmpScriptLocation = currentUsersHomeDirectory;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
//generate file with list of files found
tmpScriptLocation += ".whichBAScriptOutput";
arguments << QString(QString("which -a certainFile >> ") += tmpScriptLocation);
findFiles->setProcessEnvironment(env);
findFiles->start(program,arguments);
findFiles->waitForFinished();
which is located on /usr/bin/ so try to change the path..
EDIT:
You need to connect QProcess‘s signal readyReadStandardOutput() to your slot. Actually if you take a look at the documentation QProcess inherits from QIODevice. This means you can do something like:
if you have already written a client-server application in Qt, i am sure you reconized the pseudocode..