本文整理汇总了C++中QProcess::systemEnvironment方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::systemEnvironment方法的具体用法?C++ QProcess::systemEnvironment怎么用?C++ QProcess::systemEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::systemEnvironment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getGSLinuxPath
QString getGSLinuxPath( QString apps )
{
QStringList potential_paths;
potential_paths.append("/usr/local/bin");
potential_paths.append("/sw/bin"); /* to use on mac as same */
potential_paths.append("/opt/bin");
QProcess *process = new QProcess(NULL);
process->setReadChannelMode(QProcess::MergedChannels);
QStringList env = process->systemEnvironment();
env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;"+potential_paths.join(";"));
process->setEnvironment(env);
process->start( QString("which") , QStringList() << apps , QIODevice::ReadOnly );
if (!process->waitForFinished()) {
return QString();
} else {
QString finder = process->readAll().trimmed();
if (finder.endsWith(apps,Qt::CaseInsensitive)) {
///////////// qDebug() << "### finder " << finder;
return finder;
} else {
return QString();
}
}
}
示例2: callMaddeShellScript
bool MaemoGlobal::callMaddeShellScript(QProcess &proc,
const QString &qmakePath, const QString &command, const QStringList &args,
bool useTarget)
{
if (!QFileInfo(command).exists())
return false;
QString actualCommand = command;
QStringList actualArgs = targetArgs(qmakePath, useTarget) + args;
Environment env(proc.systemEnvironment());
addMaddeEnvironment(env, qmakePath);
proc.setEnvironment(env.toStringList());
transformMaddeCall(actualCommand, actualArgs, qmakePath);
proc.start(actualCommand, actualArgs);
return true;
}
示例3: PackageInfo
PackageInfo
UpdateProcess::packageInfo(const QString &package)
{
QProcess proc;
QStringList args;
args << "json2xml"
<< QDir::convertSeparators(updateRepositoryDir() + "/" + package);
vNotice("updater: launching auto-update executable: %1 %2")
.arg(updateExecutable())
.arg(args.join(" "));
proc.setEnvironment(proc.systemEnvironment());
proc.start(updateExecutable(), args);
if (! proc.waitForStarted())
return PackageInfo();
if (! proc.waitForFinished())
return PackageInfo();
return packageInfoFromXml(proc.readAll());
}
示例4: pageRequestedEvent
/*!
* \reimp
*/
void QxtWebCgiService::pageRequestedEvent(QxtWebRequestEvent* event)
{
// Create the process object and initialize connections
QProcess* process = new QProcess(this);
qxt_d().requests[process] = QxtCgiRequestInfo(event);
qxt_d().processes[event->content] = process;
QxtCgiRequestInfo& requestInfo = qxt_d().requests[process];
QObject::connect(process, SIGNAL(readyRead()), &qxt_d(), SLOT(processReadyRead()));
QObject::connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), &qxt_d(), SLOT(processFinished()));
QObject::connect(process, SIGNAL(error(QProcess::ProcessError)), &qxt_d(), SLOT(processFinished()));
requestInfo.timeout = new QTimer(process);
qxt_d().timeoutMapper.setMapping(requestInfo.timeout, process);
QObject::connect(requestInfo.timeout, SIGNAL(timeout()), &qxt_d().timeoutMapper, SLOT(map()));
// Initialize the system environment
QStringList s_env = process->systemEnvironment();
QMap<QString, QString> env;
foreach(const QString& entry, s_env)
{
int pos = entry.indexOf('=');
env[entry.left(pos)] = entry.mid(pos + 1);
}