本文整理汇总了C++中QProcess::setCreateProcessArgumentsModifier方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::setCreateProcessArgumentsModifier方法的具体用法?C++ QProcess::setCreateProcessArgumentsModifier怎么用?C++ QProcess::setCreateProcessArgumentsModifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::setCreateProcessArgumentsModifier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
//! [0]
QProcess process;
process.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
{
args->flags |= CREATE_NEW_CONSOLE;
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES;
args->startupInfo->dwFlags |= STARTF_USEFILLATTRIBUTE;
args->startupInfo->dwFillAttribute = BACKGROUND_BLUE | FOREGROUND_RED
| FOREGROUND_INTENSITY;
});
process.start("C:\\Windows\\System32\\cmd.exe", QStringList() << "/k" << "title" << "The Child Process");
//! [0]
return app.exec();
}
示例2: rHome
QProcess * EngineSync::startSlaveProcess(int no)
{
QDir programDir = QFileInfo( QCoreApplication::applicationFilePath() ).absoluteDir();
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString engineExe = QFileInfo( QCoreApplication::applicationFilePath() ).absoluteDir().absoluteFilePath("JASPEngine");
QStringList args;
args << QString::number(no);
args << QString::number(ProcessInfo::currentPID());
#ifdef __WIN32__
QString rHomePath = programDir.absoluteFilePath("R");
#elif __APPLE__
QString rHomePath = programDir.absoluteFilePath("../Frameworks/R.framework/Versions/" + QString::fromStdString(AppInfo::getRVersion()) + "/Resources");
#else //linux
#ifndef R_HOME
QString rHomePath = programDir.absoluteFilePath("R/lib/libR.so");
if (QFileInfo(rHomePath).exists() == false)
#ifdef FLATPAK_USED
rHomePath = "/app/lib64/R/";
#else
rHomePath = "/usr/lib/R/";
#endif
#else
QString rHomePath;
if (QDir::isRelativePath(R_HOME))
rHomePath = programDir.absoluteFilePath(R_HOME);
else
rHomePath = R_HOME;
#endif
#endif
QDir rHome(rHomePath);
#ifdef __WIN32__
#if defined(ARCH_32)
#define ARCH_SUBPATH "i386"
#else
#define ARCH_SUBPATH "x64"
#endif
env.insert("PATH", programDir.absoluteFilePath("R\\library\\RInside\\libs\\" ARCH_SUBPATH) + ";" + programDir.absoluteFilePath("R\\library\\Rcpp\\libs\\" ARCH_SUBPATH) + ";" + programDir.absoluteFilePath("R\\bin\\" ARCH_SUBPATH));
env.insert("R_HOME", rHome.absolutePath());
#undef ARCH_SUBPATH
env.insert("R_LIBS", rHome.absoluteFilePath("library"));
env.insert("R_ENVIRON", "something-which-doesnt-exist");
env.insert("R_PROFILE", "something-which-doesnt-exist");
env.insert("R_PROFILE_USER", "something-which-doesnt-exist");
env.insert("R_ENVIRON_USER", "something-which-doesnt-exist");
env.insert("R_LIBS_SITE", "something-which-doesnt-exist");
env.insert("R_LIBS_USER", "something-which-doesnt-exist");
#elif __APPLE__
env.insert("R_HOME", rHome.absolutePath());
env.insert("R_LIBS", rHome.absoluteFilePath("library") + ":" + programDir.absoluteFilePath("R/library"));
env.insert("R_ENVIRON", "something-which-doesnt-exist");
env.insert("R_PROFILE", "something-which-doesnt-exist");
env.insert("R_PROFILE_USER", "something-which-doesnt-exist");
env.insert("R_ENVIRON_USER", "something-which-doesnt-exist");
env.insert("R_LIBS_SITE", "something-which-doesnt-exist");
env.insert("R_LIBS_USER", "something-which-doesnt-exist");
#else // linux
env.insert("LD_LIBRARY_PATH", rHome.absoluteFilePath("lib") + ":" + rHome.absoluteFilePath("library/RInside/lib") + ":" + rHome.absoluteFilePath("library/Rcpp/lib") + ":" + rHome.absoluteFilePath("site-library/RInside/lib") + ":" + rHome.absoluteFilePath("site-library/Rcpp/lib") + ":/app/lib/:/app/lib64/");
env.insert("R_HOME", rHome.absolutePath());
env.insert("R_LIBS", programDir.absoluteFilePath("R/library") + ":" + rHome.absoluteFilePath("library") + ":" + rHome.absoluteFilePath("site-library"));
#endif
QProcess *slave = new QProcess(this);
slave->setProcessChannelMode(QProcess::ForwardedChannels);
slave->setProcessEnvironment(env);
slave->setWorkingDirectory(QFileInfo( QCoreApplication::applicationFilePath() ).absoluteDir().absolutePath());
#ifdef __WIN32__
/*
On Windows, QProcess uses the Win32 API function CreateProcess to
start child processes.In some casedesirable to fine-tune
the parameters that are passed to CreateProcess.
This is done by defining a CreateProcessArgumentModifier function and passing it
to setCreateProcessArgumentsModifier
bInheritHandles [in]
If this parameter is TRUE, each inheritable handle in the calling process
is inherited by the new process. If the parameter is FALSE, the handles
are not inherited.
*/
slave->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
{
#ifndef QT_DEBUG
args->inheritHandles = false;
//.........这里部分代码省略.........