当前位置: 首页>>代码示例>>C++>>正文


C++ QProcess::processEnvironment方法代码示例

本文整理汇总了C++中QProcess::processEnvironment方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::processEnvironment方法的具体用法?C++ QProcess::processEnvironment怎么用?C++ QProcess::processEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QProcess的用法示例。


在下文中一共展示了QProcess::processEnvironment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processEnvironment

QProcessEnvironment QProcessProto::processEnvironment() const
{
  QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
  if (item)
    return item->processEnvironment();
  return QProcessEnvironment();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: startProcess

/*
 * Initialize and launch process object
 */
bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args)
{
    static AssignProcessToJobObjectFun AssignProcessToJobObjectPtr = NULL;

    QMutexLocker lock(m_mutex_startProcess);
    emit messageLogged(commandline2string(program, args) + "\n");

    QProcessEnvironment env = process.processEnvironment();
    if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();
    env.insert("TEMP", QDir::toNativeSeparators(lamexp_temp_folder2()));
    env.insert("TMP", QDir::toNativeSeparators(lamexp_temp_folder2()));
    process.setProcessEnvironment(env);

    if(!AssignProcessToJobObjectPtr)
    {
        QLibrary Kernel32Lib("kernel32.dll");
        AssignProcessToJobObjectPtr = (AssignProcessToJobObjectFun) Kernel32Lib.resolve("AssignProcessToJobObject");
    }

    process.setProcessChannelMode(QProcess::MergedChannels);
    process.setReadChannel(QProcess::StandardOutput);
    process.start(program, args);

    if(process.waitForStarted())
    {

        if(AssignProcessToJobObjectPtr)
        {
            AssignProcessToJobObjectPtr(m_handle_jobObject, process.pid()->hProcess);
        }
        if(!SetPriorityClass(process.pid()->hProcess, BELOW_NORMAL_PRIORITY_CLASS))
        {
            SetPriorityClass(process.pid()->hProcess, IDLE_PRIORITY_CLASS);
        }

        lock.unlock();

        if(m_firstLaunch)
        {
            emit statusUpdated(0);
            m_firstLaunch = false;
        }

        return true;
    }

    emit messageLogged("Process creation has failed :-(");
    QString errorMsg= process.errorString().trimmed();
    if(!errorMsg.isEmpty()) emit messageLogged(errorMsg);

    process.kill();
    process.waitForFinished(-1);
    return false;
}
开发者ID:arestarh,项目名称:LameXP,代码行数:57,代码来源:Tool_Abstract.cpp

示例3: sourceWorkspace

void ROSBuildConfiguration::sourceWorkspace()
{
  // Need to source ros and devel directory to setup enviroment variables
  Utils::FileName ws_dir = target()->project()->projectDirectory();
  QProcess process;

  if (ROSUtils::sourceWorkspace(&process, ws_dir , rosDistribution()))
  {
    Utils::Environment source_env = Utils::Environment(process.processEnvironment().toStringList());
    source_env.set(QLatin1String("PWD"), ws_dir.toString());

    QList<Utils::EnvironmentItem> diff = baseEnvironment().diff(source_env);
    if (!diff.isEmpty())
      setUserEnvironmentChanges(diff);
  }
}
开发者ID:CaptD,项目名称:ros_qtc_plugin,代码行数:16,代码来源:ros_build_configuration.cpp

示例4: lamexp_init_process

/*
 * Setup QPorcess object
 */
void lamexp_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir)
{
	//Environment variable names
	static const char *const s_envvar_names_temp[] =
	{
		"TEMP", "TMP", "TMPDIR", "HOME", "USERPROFILE", "HOMEPATH", NULL
	};
	static const char *const s_envvar_names_remove[] =
	{
		"WGETRC", "SYSTEM_WGETRC", "HTTP_PROXY", "FTP_PROXY", "NO_PROXY", "GNUPGHOME", "LC_ALL", "LC_COLLATE", "LC_CTYPE", "LC_MESSAGES", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LANG", NULL
	};

	//Initialize environment
	QProcessEnvironment env = process.processEnvironment();
	if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();

	//Clean a number of enviroment variables that might affect our tools
	for(size_t i = 0; s_envvar_names_remove[i]; i++)
	{
		env.remove(QString::fromLatin1(s_envvar_names_remove[i]));
		env.remove(QString::fromLatin1(s_envvar_names_remove[i]).toLower());
	}

	const QString tempDir = QDir::toNativeSeparators(lamexp_temp_folder2());

	//Replace TEMP directory in environment
	if(bReplaceTempDir)
	{
		for(size_t i = 0; s_envvar_names_temp[i]; i++)
		{
			env.insert(s_envvar_names_temp[i], tempDir);
		}
	}

	//Setup PATH variable
	const QString path = env.value("PATH", QString()).trimmed();
	env.insert("PATH", path.isEmpty() ? tempDir : QString("%1;%2").arg(tempDir, path));
	
	//Setup QPorcess object
	process.setWorkingDirectory(wokringDir);
	process.setProcessChannelMode(QProcess::MergedChannels);
	process.setReadChannel(QProcess::StandardOutput);
	process.setProcessEnvironment(env);
}
开发者ID:BackupTheBerlios,项目名称:lamexp,代码行数:47,代码来源:Global_Utils.cpp


注:本文中的QProcess::processEnvironment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。