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


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

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


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

示例1: stepOut

void DlvDebugger::stepOut()
{
    QString cmd = LiteApi::getGotools(m_liteApp);
    QProcess process;
    process.setEnvironment(LiteApi::getCurrentEnvironment(m_liteApp).toStringList());
    QFileInfo info(m_lastFileName);
    process.setWorkingDirectory(info.path());
    QStringList args;
    args << "finddecl" << "-file" << info.fileName() << "-line" << QString("%1").arg(m_lastFileLine+1);
    process.start(cmd,args);
    if (!process.waitForFinished(3000)) {
        emit debugLog(LiteApi::DebugErrorLog,"error wait find decl process");
        process.kill();
        return;
    }
    if (process.exitCode() != 0) {
        emit debugLog(LiteApi::DebugErrorLog,"error get find decl result");
        return;
    }
    QByteArray data = process.readAll().trimmed();
    QStringList ar = QString::fromUtf8(data).split(" ");
    if (ar.size() != 4 || ar[0] != "func") {
        emit debugLog(LiteApi::DebugErrorLog,"error find func decl in line");
        return;
    }
    m_funcDecl.fileName = m_lastFileName;
    m_funcDecl.funcName = ar[1];
    m_funcDecl.start = ar[2].toInt()-1;
    m_funcDecl.end = ar[3].toInt()-1;
    m_checkFuncDecl = true;
    command("next");
}
开发者ID:AChinaProgrammer,项目名称:liteide,代码行数:32,代码来源:dlvdebugger.cpp

示例2: on_btnStart_clicked

void MainWindow::on_btnStart_clicked()
{
    if (!QFile(programPath).exists()) {
        QMessageBox::warning(this,
                             tr("Невозможно запустить процесс"),
                             tr("Не найден файл программы.\n"
                                "Возможно, не указан путь к файлу gostunnel.exe"));
        return;
    }
    if (ui->lwGroups->count() == 0) {
        return;
    }
    QString el = ui->lwGroups->currentItem()->text();
    QProcess *proc = connections.value(el);
    if (proc->pid() <= 0) {
        QDir wd = QDir(programPath);
        wd.cdUp();
        proc->setWorkingDirectory(wd.path());
        QStringList args;
        args << "--config" << programConfig
             << "-s" << el;
        connect(proc, SIGNAL(error(QProcess::ProcessError)),
                this, SLOT(processError(QProcess::ProcessError)));
        connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)),
                this, SLOT(processFinished(int,QProcess::ExitStatus)));
        connect(proc, SIGNAL(stateChanged(QProcess::ProcessState)),
                this, SLOT(processStateChenged(QProcess::ProcessState)));
        connect(proc, SIGNAL(readyReadStandardError()),
                this, SLOT(processReadyReadError()));
        connect(proc, SIGNAL(started()),
                this, SLOT(processStarted()));
        ui->lwGroups->currentItem()->setBackgroundColor(QColor::fromRgb(255, 233, 113));
        proc->start(programPath, args);
    }
开发者ID:w3tl,项目名称:gostunnel,代码行数:34,代码来源:mainwindow.cpp

示例3: normalize

void normalize( const QString &output )
{
    QProcess vorbisgain;
    vorbisgain.setWorkingDirectory( output );
    vorbisgain.start( "vorbisgain", QStringList() << "-a" << tomTomFiles() << marbleFiles() );
    vorbisgain.waitForFinished();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: run

void ImportThread::run()
{	
	QProcess compileProcess;
	QString processBin = QString();
	
	if ((Preferences::p_getCompiler()=="latex")||(Preferences::p_getCompiler()=="tex"))
	{
		processBin=Preferences::p_getLtx2pdf();
	}
	else processBin=Preferences::p_getBin(Preferences::p_getCompiler());
	
#ifndef Q_OS_WIN
	QStringList env = QProcess::systemEnvironment();
	int j = env.indexOf(QRegExp("^PATH=(.*)"));
	int limit = env.at(j).indexOf("=");
	QString value = env.at(j).right(env.at(j).size()-limit-1).trimmed();
	value = "PATH=" + value + ":" + QFileInfo(processBin).path() + ":" + QFileInfo(Preferences::p_getBin("latex")).path() + ":" + QFileInfo(Preferences::p_getBin("dvips")).path() + ":" + QFileInfo(Preferences::p_getBin("ps2pdf")).path();
        env.replace(j,value);
	compileProcess.setEnvironment(env);
#endif
	
	int listLen = fileList.size();
	
	QString exoFile;
	QMap<QString,QString> * exoMap = new QMap<QString,QString>;
	
	for (int i=0; i<listLen; i++)
		{	
			exoMap = new QMap<QString,QString>;
			*exoMap = fileList.at(i);
			exoFile = exoMap->value("filepath");
			compileProcess.setWorkingDirectory(QFileInfo(exoFile).path());
			QStringList args;
			QString tmpFileName = QFileInfo(exoFile).baseName() + "-preview.tex";
			
			if ((Preferences::p_getCompiler()=="latex")||(Preferences::p_getCompiler()=="tex"))
			{ 
#ifdef Q_OS_WIN
				args << QFileInfo(exoFile).baseName() + "-preview" << Preferences::p_getBin("latex") << Preferences::p_getBin("dvips") << Preferences::p_getBin("ps2pdf") << Preferences::p_getCompilationOptions();
#else
                              args << "-c" << tmpFileName << Preferences::p_getBin("latex") << Preferences::p_getBin("dvips") << Preferences::p_getBin("ps2pdf") << Preferences::p_getCompilationOptions();
                //             args << "-c" << tmpFileName << "latex" << "dvips" << "ps2pdf" << Preferences::p_getCompilationOptions();
#endif
			}
			else args << Preferences::p_getCompilationOptions() << tmpFileName;
	
			// On exécute la compilation
			compileProcess.start(processBin,args);
			compileProcess.waitForFinished(-1);
			QString errorOutput = compileProcess.readAll();
			QString outName=QString();
			outName = QFileInfo(exoFile).path() + QDir::separator()+ QFileInfo(exoFile).baseName()+"-preview.pdf";
			
			QFile outFile;
			if (outFile.exists(outName)) {	emit exoTreated(exoMap);		} 
				else emit errorOccured(exoFile,errorOutput);
			exoMap->~QMap();
		}
}
开发者ID:schlecky,项目名称:texomaker,代码行数:59,代码来源:importthread.cpp

示例5: programPath

QProcess * Engine::run(QFileInfo input, QObject * parent /* = nullptr */)
{
	QString exeFilePath = programPath(program());
	if (exeFilePath.isEmpty())
		return nullptr;

	QStringList env = QProcess::systemEnvironment();
	QProcess * process = new QProcess(parent);

	QString workingDir = input.canonicalPath();
#if defined(Q_OS_WIN)
	// files in the root directory of the current drive have to be handled specially
	// because QFileInfo::canonicalPath() returns a path without trailing slash
	// (i.e., a bare drive letter)
	if (workingDir.length() == 2 && workingDir.endsWith(QChar::fromLatin1(':')))
		workingDir.append(QChar::fromLatin1('/'));
#endif
	process->setWorkingDirectory(workingDir);


#if !defined(Q_OS_DARWIN) // not supported on OS X yet :(
	// Add a (customized) TEXEDIT environment variable
	env << QString::fromLatin1("TEXEDIT=%1 --position=%d %s").arg(QCoreApplication::applicationFilePath());

	#if defined(Q_OS_WIN) // MiKTeX apparently uses it's own variable
	env << QString::fromLatin1("MIKTEX_EDITOR=%1 --position=%l \"%f\"").arg(QCoreApplication::applicationFilePath());
	#endif
#endif

	QStringList args = arguments();

	// for old MikTeX versions: delete $synctexoption if it causes an error
	static bool checkedForSynctex = false;
	static bool synctexSupported = true;
	if (!checkedForSynctex) {
		QString pdftex = programPath(QString::fromLatin1("pdftex"));
		if (!pdftex.isEmpty()) {
			int result = QProcess::execute(pdftex, QStringList() << QString::fromLatin1("-synctex=1") << QString::fromLatin1("-version"));
			synctexSupported = (result == 0);
		}
		checkedForSynctex = true;
	}
	if (!synctexSupported)
		args.removeAll(QString::fromLatin1("$synctexoption"));

	args.replaceInStrings(QString::fromLatin1("$synctexoption"), QString::fromLatin1("-synctex=1"));
	args.replaceInStrings(QString::fromLatin1("$fullname"), input.fileName());
	args.replaceInStrings(QString::fromLatin1("$basename"), input.completeBaseName());
	args.replaceInStrings(QString::fromLatin1("$suffix"), input.suffix());
	args.replaceInStrings(QString::fromLatin1("$directory"), input.absoluteDir().absolutePath());

	process->setEnvironment(env);
	process->setProcessChannelMode(QProcess::MergedChannels);

	process->start(exeFilePath, args);

	return process;
}
开发者ID:mojca,项目名称:texworks,代码行数:58,代码来源:Engine.cpp

示例6: buildHelper

bool BuildableHelperLibrary::buildHelper(const BuildHelperArguments &arguments,
                                         QString *log, QString *errorMessage)
{
    const QChar newline = QLatin1Char('\n');
    // Setup process
    QProcess proc;
    proc.setEnvironment(arguments.environment.toStringList());
    proc.setWorkingDirectory(arguments.directory);
    proc.setProcessChannelMode(QProcess::MergedChannels);

    log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                          "Building helper \"%1\" in %2\n").arg(arguments.helperName,
                                                                              arguments.directory));
    log->append(newline);

    const FileName makeFullPath = arguments.environment.searchInPath(arguments.makeCommand);
    if (QFileInfo::exists(arguments.directory + QLatin1String("/Makefile"))) {
        if (makeFullPath.isEmpty()) {
            *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
                                                       "%1 not found in PATH\n").arg(arguments.makeCommand);
            return false;
        }
        const QString cleanTarget = QLatin1String("distclean");
        log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                                   "Running %1 %2...\n")
                    .arg(makeFullPath.toUserOutput(), cleanTarget));
        if (!runBuildProcess(proc, makeFullPath, QStringList(cleanTarget), 30, true, log, errorMessage))
            return false;
    }
    QStringList qmakeArgs;
    if (!arguments.targetMode.isEmpty())
        qmakeArgs << arguments.targetMode;
    if (!arguments.mkspec.isEmpty())
        qmakeArgs << QLatin1String("-spec") << arguments.mkspec.toUserOutput();
    qmakeArgs << arguments.proFilename;
    qmakeArgs << arguments.qmakeArguments;

    log->append(newline);
    log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                            "Running %1 %2 ...\n").arg(arguments.qmakeCommand.toUserOutput(),
                                                                       qmakeArgs.join(QLatin1Char(' '))));

    if (!runBuildProcess(proc, arguments.qmakeCommand, qmakeArgs, 30, false, log, errorMessage))
        return false;
    log->append(newline);
    if (makeFullPath.isEmpty()) {
        *errorMessage = QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                                "%1 not found in PATH\n").arg(arguments.makeCommand);
        return false;
    }
    log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                            "Running %1 %2 ...\n")
                .arg(makeFullPath.toUserOutput(), arguments.makeArguments.join(QLatin1Char(' '))));
    if (!runBuildProcess(proc, makeFullPath, arguments.makeArguments, 120, false, log, errorMessage))
        return false;
    return true;
}
开发者ID:NamiStudio,项目名称:qt-creator,代码行数:57,代码来源:buildablehelperlibrary.cpp

示例7: run

    void run()
    {
        QProcess process;
        QString dir = QCoreApplication::applicationDirPath() + "/plugins/hilec";
        process.setWorkingDirectory(dir);
        process.start(dir + "/compile.bat", QStringList(QFileInfo(mFile).canonicalFilePath()) << mBase);
        if(!process.waitForFinished(5000))
        {
            QByteArray standardOutput = process.readAllStandardOutput();
            if(!standardOutput.isEmpty()){
                qDebug() << standardOutput;
            }
            QByteArray standardError = process.readAllStandardError();
            if(!standardError.isEmpty()){
                qDebug() << standardError;
            }
            process.kill();
            return;
        }

        QString str = process.readAllStandardOutput();
        QStringList errors = str.split("\n", QString::SkipEmptyParts);
        ScriptCompileInfo info;
        info.file = mFile;
        QDir baseDir(mBase);
        foreach(QString line, errors)
        {
            ScriptCompileProblem problem;
            QStringList parts = line.split(":");
            if(parts.size() < 3)
                continue;
            QString file = parts.takeFirst();
            if(file.size() == 1) // this is a windows disc
                file += ":" + parts.takeFirst();
            if(QFileInfo(baseDir.absoluteFilePath(file)) != QFileInfo(mFile))
                continue;
            if(parts.size() < 2)
                continue;
            problem.line = parts.takeFirst().toInt();
            QString msg = parts.join(":").trimmed().mid(1);
            int pos = msg.indexOf("]");
            if(pos < 1)
                continue;
            QChar mode = msg[0];
            if(mode == 'E' || mode == 'F')
                problem.mode = ScriptCompileProblem::Error;
            else if(mode == 'W')
                problem.mode = ScriptCompileProblem::Warning;
            else if(mode == 'C')
                problem.mode = ScriptCompileProblem::Info;
            else
                continue;
            problem.msg = msg.mid(pos + 1).trimmed();
            info.problems << problem;
            //qDebug() << mode << msg;
        }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例8: runPatch

bool PatchTool::runPatch(const QByteArray &input, const QString &workingDirectory,
                         int strip, bool reverse)
{
    const QString patch = patchCommand();
    if (patch.isEmpty()) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "There is no patch-command configured in the general \"Environment\" settings."));
        return false;
    }

    QProcess patchProcess;
    if (!workingDirectory.isEmpty())
        patchProcess.setWorkingDirectory(workingDirectory);
    QStringList args;
    // Add argument 'apply' when git is used as patch command since git 2.5/Windows
    // no longer ships patch.exe.
    if (patch.endsWith(QLatin1String("git"), Qt::CaseInsensitive)
        || patch.endsWith(QLatin1String("git.exe"), Qt::CaseInsensitive)) {
        args << QLatin1String("apply");
    }
    if (strip >= 0)
        args << (QLatin1String("-p") + QString::number(strip));
    if (reverse)
        args << QLatin1String("-R");
    MessageManager::write(QApplication::translate("Core::PatchTool", "Executing in %1: %2 %3").
                          arg(QDir::toNativeSeparators(workingDirectory),
                              QDir::toNativeSeparators(patch), args.join(QLatin1Char(' '))));
    patchProcess.start(patch, args);
    if (!patchProcess.waitForStarted()) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "Unable to launch \"%1\": %2").arg(patch, patchProcess.errorString()));
        return false;
    }
    patchProcess.write(input);
    patchProcess.closeWriteChannel();
    QByteArray stdOut;
    QByteArray stdErr;
    if (!Utils::SynchronousProcess::readDataFromProcess(patchProcess, 30, &stdOut, &stdErr, true)) {
        Utils::SynchronousProcess::stopProcess(patchProcess);
        MessageManager::write(QApplication::translate("Core::PatchTool", "A timeout occurred running \"%1\"").arg(patch));
        return false;

    }
    if (!stdOut.isEmpty())
        MessageManager::write(QString::fromLocal8Bit(stdOut));
    if (!stdErr.isEmpty())
        MessageManager::write(QString::fromLocal8Bit(stdErr));

    if (patchProcess.exitStatus() != QProcess::NormalExit) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "\"%1\" crashed.").arg(patch));
        return false;
    }
    if (patchProcess.exitCode() != 0) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "\"%1\" failed (exit code %2).").arg(patch).arg(patchProcess.exitCode()));
        return false;
    }
    return true;
}
开发者ID:hoangHEDSPI,项目名称:qt-creator,代码行数:56,代码来源:patchtool.cpp

示例9: on_pushButton_clicked

void MainWindow::on_pushButton_clicked()   // process one should be launched (bash launches)
{
    QProcess *proc = new QProcess();
    proc->setWorkingDirectory("/home/kondo/");
    proc->start("/bin/bash", QStringList() << "/home/syed/backup.sh");
    qDebug() << "Error in opening the file =" << proc->errorString();
   // MainWindow::on_checkBox_2_stateChanged(0);
  //  MainWindow::pushbutton3(TRUE);

}
开发者ID:RahulKondi,项目名称:debChive,代码行数:10,代码来源:mainwindow.cpp

示例10: copyCheckPointFiles

//////// NOT USED //////////
void Gridifier::copyCheckPointFiles(const QString &host){
  QProcess *rgcpcProcess = new QProcess(QString("./rgcpc.pl"));
  rgcpcProcess->setWorkingDirectory(mScriptsDir);
  rgcpcProcess->addArgument("-t");
  rgcpcProcess->addArgument(host);
  rgcpcProcess->addArgument("-f");
  rgcpcProcess->addArgument("checkPointDataCache.xml");
  rgcpcProcess->start();

  // and then do something clever to give the users an update status on the file transfer progress
}
开发者ID:RealityGrid,项目名称:qt_launcher,代码行数:12,代码来源:Gridifier.cpp

示例11: runMercurial

bool versionControl::runMercurial(QString options) {

    if (!this->isMercurialThere)
        return false;

    QSettings settings;

    // get current model path from QSettings

    QString path = settings.value("files/currentFileName", "No model").toString();

    if (path == "No model")
        return false;

    // set up the environment for the spawned processes
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("PATH", qgetenv("PATH"));
    // to be used as a username if one is not set
    env.insert("EMAIL", QHostInfo::localHostName());

    // make the QProcess
    QProcess * mercurial = new QProcess;
    mercurial->setWorkingDirectory(QDir::toNativeSeparators(path));
    mercurial->setProcessEnvironment(env);

    connect(mercurial, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
    connect(mercurial, SIGNAL(readyReadStandardOutput()), this, SLOT(standardOutput()));
    connect(mercurial, SIGNAL(readyReadStandardError()), this, SLOT(standardError()));

    // clear stdOut & stdErr texts
    stdOutText.clear();
    stdErrText.clear();

    // launch
    mercurial->start("hg " + options);

    // wait until complete, or 3 s
    bool noerror = mercurial->waitForFinished(3000);

    if (noerror) {
        // check output
        if (mercurial->exitCode() == 0) {
            delete mercurial;
            return true;
        } else {
            delete mercurial;
            return false;
        }

    }
    delete mercurial;
    return false;

}
开发者ID:ajc158,项目名称:spinecreator,代码行数:54,代码来源:versioncontrol.cpp

示例12: compile

int RSLOutputNode::compile()    const
{
    QProcess *process = new QProcess();
    QStringList arguments;
    arguments << getFileName();
    process->setStandardErrorFile("compiler.log");
    process->setWorkingDirectory(QFileInfo(getFileName()).canonicalPath());
    process->start("shaderdl", arguments);
    process->waitForFinished(10000);
    return 1;
}
开发者ID:frigge,项目名称:MindTree,代码行数:11,代码来源:outputs.cpp

示例13: start

bool OpenModelica::start(QString exeFile,QString &errMsg,int maxnsec)
{

    QFileInfo exeFileInfo(exeFile);
    QString exeDir = exeFileInfo.absolutePath();
    if(!QFile::exists(exeFile))
    {
        errMsg = "Cannot find model executable file : " + exeFile;
        return false;
    }

    QProcess simProcess;
    simProcess.setWorkingDirectory(exeDir);


#ifdef WIN32
    QString appPath = "\""+exeFile+"\"";
    // add OM path in PATH
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString omHome = env.value("OpenModelicaHome");
    omHome = omHome+QDir::separator()+"bin";
    QString mingw = env.value("OpenModelicaHome");
    mingw = mingw+QDir::separator()+"MinGW"+QDir::separator()+"bin";
    env.insert("PATH", env.value("Path") + ";"+omHome+";"+mingw);

    simProcess.setProcessEnvironment(env);

    //start process
    simProcess.start(appPath, QStringList());
#else
    QStringList arguments;
    arguments << "-c";
    arguments << "./"+exeFileInfo.fileName() << " > log.txt";
    simProcess.start("sh", arguments);
#endif

    int nmsec;
    if(maxnsec==-1)
        nmsec = -1;
    else
        nmsec = maxnsec*1000;
    bool ok = simProcess.waitForFinished(nmsec);
    if(!ok)
    {
        errMsg = "Simulation process failed or time limit reached";
        simProcess.close();
        return false;
    }

    QString output(simProcess.readAllStandardOutput());
    InfoSender::instance()->send(Info(output,ListInfo::OMCNORMAL2));
    return ok;
}
开发者ID:cephdon,项目名称:OMOptim,代码行数:53,代码来源:OpenModelica.cpp

示例14: execGzipCmd

void Compress::execGzipCmd(const QString& savedFilename, const QString &sourceDir)
{
   QProcess process;
   QStringList args;
   process.setWorkingDirectory(QFileInfo(m_buildDir).absolutePath());
   args << "-czvf" << savedFilename << sourceDir;
   process.start("tar", args);
   bool status = process.waitForFinished(-1);
   if(!status || process.exitCode() != 0){
      throw ErrorInfo(process.errorString());
   }
}
开发者ID:asdf20122012,项目名称:releasemgr,代码行数:12,代码来源:compress.cpp

示例15: showAssfreezer

void MainDialog::showAssfreezer()
{
	if( !QFile::exists( cAFPath ) ) {
		QMessageBox::warning( this, "Assfreezer Missing", "Assfreezer could not be found at: " + cAFPath );
		return;
	}
	QProcess * p = new QProcess(this);
	// Delete Automatically when assfreezer exits
	connect( p, SIGNAL( finished ( int, QProcess::ExitStatus ) ), p, SLOT(deleteLater()));
	p->setWorkingDirectory( QFileInfo(cAFPath).path() );
	p->start( cAFPath, QStringList() << "-current-render" );
}
开发者ID:EntityFXCode,项目名称:arsenalsuite,代码行数:12,代码来源:maindialog.cpp


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