I use Ubuntu 12.04.
Code:
#include <QApplication>
#include <QDebug>
int main(int argc, char* argv[]){
QApplication app(argc, argv);
QProcessEnvironment environment;
qDebug() << environment.toStringList();
return app.exec();
}
Output:
()
env command returns a non-empty list of environment variables.
How to solve this problem? What’s wrong?
You should call
QProcessEnvironment::systemEnvironment()to get the environment of the calling process. Now you’re just creating an empty environment. See Qt documentation.