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


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

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


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

示例1: run

void closeAllVolumesThread::run()
{
	m_table->setEnabled( false );
	sleep( 1 ) ; // for ui effect
	int i = m_table->rowCount() ;

	if( i < 1 ){
		m_table->setEnabled( true );
		return ;
	}

	int j = -1 ;

	QVector<QTableWidgetItem*> tableItems( 0 ) ;

	QTableWidgetItem * deviceItem ;

	while( ++j < i ){
		tableItems.append( m_table->item( j,0 ) );
	}
	
	QProcess p ;
	QString exe ;
	QString device ;

	for( j = 0 ; j < i ; j++ ){
		deviceItem = tableItems.at( j ) ;
		device = deviceItem->text().replace( "\"","\"\"\"" ) ;
		exe = QString( "%1 -q -d \"%2\"" ).arg( ZULUCRYPTzuluCrypt ).arg( device ) ;
		p.start( exe );
		p.waitForFinished() ;
		emit close( deviceItem,p.exitCode() ) ;
		p.close();
		sleep( 1 ) ; // for ui effect
	}
	
	m_table->setEnabled( true );
}
开发者ID:Salan54,项目名称:zuluCrypt,代码行数:38,代码来源:closeallvolumesthread.cpp

示例2: transform

OutputList Class::transform(const QStringList &input, Options &options) const
{
	Output ret;
	ret.setFiles(input);
	
	QProcess compiler;
	QString output = (options.contains(OUTPUT_DIR) ? options[OUTPUT_DIR].toString() : QFileInfo(input[0]).absolutePath() + "/a.jar");
	
	compiler.start(jarPath(), (QStringList() << "cvf" << output) + input);
	if(!compiler.waitForStarted()) {
		ret = Output(Platform::ccPath(), 1, "", "error: couldn't start the java archiver");
		return OutputList() << ret;
	}
	compiler.waitForFinished();
	
	ret.setExitCode(compiler.exitCode());
	ret.setOutput(compiler.readAllStandardOutput());
	ret.setError(compiler.readAllStandardError());
	ret.setGeneratedFiles(QStringList() << output);
  ret.setTerminal(Output::BinaryTerminal);
	
	return OutputList() << ret;
}
开发者ID:kipr,项目名称:pcompiler,代码行数:23,代码来源:class.cpp

示例3: main

int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    app.setApplicationName("Flush");
    QStringList args=app.arguments();
    args.removeFirst();
    QString appl=args.at(0);
    args.removeFirst();
    QProcess p;
    p.setProcessChannelMode(QProcess::ForwardedChannels);
    p.start(appl,args);
    p.waitForFinished(-1);
    Phonon::MediaObject *mediaObject = new Phonon::MediaObject();
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
    Phonon::createPath(mediaObject, audioOutput);
    if(p.exitCode()==0)
      mediaObject->setCurrentSource(Phonon::MediaSource(":/flush.ogg"));
    else
      mediaObject->setCurrentSource(Phonon::MediaSource(":/sadtrombone.ogg"));
    mediaObject->play();
    QObject::connect(mediaObject,SIGNAL(finished()),&app,SLOT(quit()));
    return app.exec();
}
开发者ID:admiral0,项目名称:flush,代码行数:23,代码来源:main.cpp

示例4: execute

/*!
   \param program The program to execute.
   \param arguments The arguments to be passed to the program.
   \return The exit code of the executed program.
    Starts a program with arguments in a new process, waits for it to finish, and then returns
    the exit code of the process. Any data the new process writes to the console is forwarded to
    the calling process.

    The environment and working directory are inherited by the calling process.

    On Windows, arguments that contain spaces are wrapped in quotes.
*/
int TSystem::execute(const QString &program, const QStringList &arguments) const
{
    QDEBUG_METHOD_NAME;

    QProcess process;

    // As seen in http://jira.codehaus.org/browse/IZPACK-20 and http://labs.trolltech.com/forums/topic/156, the method
    // execute() from QProcess is not used.

    qDebug() << TDebug::indentation << "Going to execute: " << program << " with arguments: " << arguments;

    process.setReadChannelMode(QProcess::ForwardedChannels);
    process.start(program, arguments);
    process.waitForFinished(-1);

    int exitCode = process.exitCode();
    if (process.error() == QProcess::FailedToStart)
    {
       exitCode = -1;
    }

    return exitCode;
}
开发者ID:BackupTheBerlios,项目名称:nxspooler-svn,代码行数:35,代码来源:tsystem.cpp

示例5: nextPort

Utils::Port IosSimulator::nextPort() const
{
    for (int i = 0; i < 100; ++i) {
        // use qrand instead?
        if (++m_lastPort >= Constants::IOS_SIMULATOR_PORT_END)
            m_lastPort = Constants::IOS_SIMULATOR_PORT_START;
        QProcess portVerifier;
        // this is a bit too broad (it does not check just listening sockets, but also connections
        // to that port from this computer)
        portVerifier.start(QLatin1String("lsof"), QStringList() << QLatin1String("-n")
                         << QLatin1String("-P") << QLatin1String("-i")
                         << QString::fromLatin1(":%1").arg(m_lastPort));
        if (!portVerifier.waitForStarted())
            break;
        portVerifier.closeWriteChannel();
        if (!portVerifier.waitForFinished() && portVerifier.state() == QProcess::Running)
            break;
        if (portVerifier.exitStatus() != QProcess::NormalExit
                || portVerifier.exitCode() != 0)
            break;
    }
    return Utils::Port(m_lastPort);
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:23,代码来源:iossimulator.cpp

示例6: useTesseract

bool MainForm::useTesseract(const QString &inputFile)
{
    QProcess proc;
    proc.setWorkingDirectory(workingDir);
    QStringList sl;
    sl.append(inputFile);
    sl.append(outputBase);
    sl.append("-l");
    sl.append(tesMap->value(settings.getLanguage()));
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TESSDATA_PREFIX", settings.getTessdataPath());
    proc.setProcessEnvironment(env);
    proc.start("tesseract", sl);
    proc.waitForFinished(-1);
    if (proc.exitCode()) {
        QByteArray stdout = proc.readAllStandardOutput();
        QByteArray stderr = proc.readAllStandardError();
        QString output = QString(stdout) + QString(stderr);
        QMessageBox::critical(this, trUtf8("Starting tesseract failed"), trUtf8("The system said: ") + (output != "" ? output : trUtf8("program not found")));
        return false;
    }
    return true;
}
开发者ID:andrei-b,项目名称:YAGF,代码行数:23,代码来源:mainform.cpp

示例7: compareFiles

bool MTest::compareFiles(const QString& saveName, const QString& compareWith) const
      {
      QString cmd = "diff";
      QStringList args;
      args.append("-u");
      args.append("--strip-trailing-cr");
      args.append(saveName);
      args.append(root + "/" + compareWith);
      QProcess p;
qDebug() << "Running " << cmd << " with arg1:" << saveName << " and arg2: " << compareWith;
      p.start(cmd, args);
      if (!p.waitForFinished() || p.exitCode()) {
            QByteArray ba = p.readAll();
            //qDebug("%s", qPrintable(ba));
            //qDebug("   <diff -u %s %s failed", qPrintable(saveName),
            //   qPrintable(QString(root + "/" + compareWith)));
            QTextStream outputText(stdout);
            outputText << QString(ba);
            outputText << QString("   <diff -u %1 %2 failed").arg(QString(saveName)).arg(QString(root + "/" + compareWith));
            return false;
            }
      return true;
      }
开发者ID:ajyoon,项目名称:MuseScore,代码行数:23,代码来源:testutils.cpp

示例8: selectSticker

void ChibiTest::selectSticker(int stickerNum)
{
    QProcess s;

    emit testMessage(testName(), setStickerNum, stickerNum, "");

    if (stickerNum > 4)
        return;

    s.start("./select_sticker", QStringList() << QString::number(stickerNum));

    if (!s.waitForStarted()) {
        testError("Unable to select sticker");
        return;
    }

    s.closeWriteChannel();
    s.waitForFinished();
    if (s.exitCode()) {
        testError(QString("select_sticker returned an error: ") + s.readAll());
        return;
    }
}
开发者ID:xobs,项目名称:chibitronics-jig,代码行数:23,代码来源:chibitest.cpp

示例9: remoteModificationTime

unsigned int AndroidDeployStep::remoteModificationTime(const QString &fullDestination, QHash<QString, unsigned int> *cache)
{
    QString destination = QFileInfo(fullDestination).absolutePath();
    QProcess process;
    QHash<QString, unsigned int>::const_iterator it = cache->find(fullDestination);
    if (it != cache->constEnd())
        return *it;
    QStringList arguments = AndroidDeviceInfo::adbSelector(m_deviceSerialNumber);
    arguments << QLatin1String("ls") << destination;
    process.start(AndroidConfigurations::instance().adbToolPath().toString(), arguments);
    process.waitForFinished(-1);
    if (process.error() != QProcess::UnknownError
            || process.exitCode() != 0)
        return -1;
    QByteArray output = process.readAll();
    output.replace("\r\n", "\n");
    QList<QByteArray> lines = output.split('\n');
    foreach (const QByteArray &line, lines) {
        // do some checks if we got what we expected..
        if (line.count() < (3 * 8 + 3))
            continue;
        if (line.at(8) != ' '
                || line.at(17) != ' '
                || line.at(26) != ' ')
            continue;
        bool ok;
        int time = line.mid(18, 8).toUInt(&ok, 16);
        if (!ok)
            continue;
        QString fileName = QString::fromLocal8Bit(line.mid(27));
        cache->insert(destination + QLatin1Char('/') + fileName, time);
    }
    it = cache->find(fullDestination);
    if (it != cache->constEnd())
        return *it;
    return 0;
}
开发者ID:Revulet,项目名称:qtcreator,代码行数:37,代码来源:androiddeploystep.cpp

示例10: openInNativeExtension

bool openInNativeExtension(const QString &path) {
#if defined(Q_OS_WIN32)
    //call ShellExecute internally
    return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
#elif defined(Q_OS_MAC)
    // mac's open program, it will fork to open the file in a subprocess
    // so we will wait for it to check whether it succeeds or not
    QProcess subprocess;
    subprocess.start(QLatin1String("open"), QStringList(path));
    subprocess.waitForFinished(-1);
    return subprocess.exitCode() == 0;
#elif defined(Q_OS_LINUX)
    // unlike mac's open program, xdg-open won't fork a new subprocess to open
    // the file will block until the application returns, so we won't wait for it
    // and we need another approach to check if it works

    // find out if the file can be opened by xdg-open, xdg-mime
    // usually they are installed in xdg-utils installed by default
    QString mime_type;
    if (!getMimeTypeFromXdgUtils(path, &mime_type))
        return false;
    // don't open this type of files from xdg-mime
    if (mime_type == "application/octet-stream")
        return false;
    // in fact we need to filter out files like application/x-executable
    // but it is not necessary since getMimeTypeFromXdg will return false for
    // it!
    QString application;
    if (!getOpenApplicationFromXdgUtils(mime_type, &application))
        return false;

    return QProcess::startDetached(QLatin1String("xdg-open"),
                                   QStringList(path));
#else
    return false;
#endif
}
开发者ID:beng81,项目名称:seafile-client,代码行数:37,代码来源:utils.cpp

示例11: runCallgrindSubProcess

// Reruns this program through callgrind, storing callgrind result files in the
// current directory.
// Returns true upon success, otherwise false.
bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
{
    const QString execFile(origAppArgs.at(0));
    QStringList args;
    args << QLatin1String("--tool=callgrind") << QLatin1String("--instr-atstart=yes")
         << QLatin1String("--quiet")
         << execFile << QLatin1String("-callgrindchild");

#if (defined Q_WS_QWS)
    // While running the child process, we aren't processing events, and hence aren't
    // acting as the QWS server. Therefore it's necessary to tell the child to act
    // as its own server instead of connecting to us.
    args << QLatin1String("-qws");
#endif

    // pass on original arguments that make sense (e.g. avoid wasting time producing output
    // that will be ignored anyway) ...
    for (int i = 1; i < origAppArgs.size(); ++i) {
        const QString arg(origAppArgs.at(i));
        if (arg == QLatin1String("-callgrind"))
            continue;
        args << arg; // ok to pass on
    }

    QProcess process;
    process.start(QLatin1String("valgrind"), args);
    process.waitForStarted(-1);
    QBenchmarkGlobalData::current->callgrindOutFileBase =
        QBenchmarkValgrindUtils::outFileBase(process.pid());
    const bool finishedOk = process.waitForFinished(-1);
    exitCode = process.exitCode();

    dumpOutput(process.readAllStandardOutput(), stdout);
    dumpOutput(process.readAllStandardError(), stderr);

    return finishedOk;
}
开发者ID:BGmot,项目名称:Qt,代码行数:40,代码来源:qbenchmarkvalgrind.cpp

示例12: System

int System(const QString exename, const QStringList & args, const QString fileStdErr, const QString fileStdOut, bool* cancel)
{
	QProcess proc;
	if (!fileStdOut.isEmpty())
		proc.setStandardOutputFile(fileStdOut);
	if (!fileStdErr.isEmpty())
		proc.setStandardErrorFile(fileStdErr);
	proc.start(exename, args);
	if (proc.waitForStarted(15000))
	{
		while (!proc.waitForFinished(15000))
		{
			qApp->processEvents();
			if (cancel && (*cancel == true))
			{
				proc.kill();
				break;
			}
		}
	}
	if (cancel && (*cancel == true))
		return -1;
	return proc.exitCode();
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:24,代码来源:util.cpp

示例13: QStringList

/**
 * Returns the complete python version
 * eg 2.7.9
 * Make sure to have setup python first
 */
QString Utils::Misc::pythonVersionComplete() {
    static QString version;
    if (version.isEmpty()) {
        if (pythonExecutable().isEmpty())
            return version;
        QProcess pythonProc;
        pythonProc.start(pythonExecutable(), QStringList() << "--version", QIODevice::ReadOnly);
        if (pythonProc.waitForFinished() && pythonProc.exitCode() == 0) {
            QByteArray output = pythonProc.readAllStandardOutput();
            if (output.isEmpty())
                output = pythonProc.readAllStandardError();

            // Software 'Anaconda' installs its own python interpreter
            // and `python --version` returns a string like this:
            // `Python 3.4.3 :: Anaconda 2.3.0 (64-bit)`
            const QList<QByteArray> verSplit = output.split(' ');
            if (verSplit.size() > 1) {
                version = verSplit.at(1).trimmed();
                Logger::instance()->addMessage(QCoreApplication::translate("misc", "Python version: %1").arg(version), Log::INFO);
            }
        }
    }
    return version;
}
开发者ID:RavenB,项目名称:qBittorrent,代码行数:29,代码来源:misc.cpp

示例14: close

/*! Close the current backup (encrypted or unencrypted)
 *
 * \return success, failed or what else
 */
Backup::Status Backup::close()
{
    QProcess process;
    QDir dir;

    if (!isOpen()) {
        return Backup::Success;
    }

    switch (m_encryption) {
        case Backup::NotEncrypted:
            break;

        case Backup::EncFSEncrypted:
            process.start("fusermount", QStringList() << "-u" << m_location);
            process.waitForStarted();
            process.waitForFinished();

            m_errorString = process.readAllStandardError();
            m_rc = process.exitCode();

            if (m_rc != 0) {
                return Backup::Failed;
            }

            dir.rmdir(m_location);
            break;

        default:
            return Backup::Failed;
            break;
    }

    m_isOpen = false;
    return Backup::Success;
}
开发者ID:mweidler,项目名称:Inverita,代码行数:40,代码来源:Backup.cpp

示例15: done

void HgCreateDialog::done(int r)
{
    if (r == KDialog::Accepted) {
        QProcess process;
        QStringList args;
        args << QLatin1String("init");
        if (!m_repoNameEdit->text().isEmpty()) {
            args << m_repoNameEdit->text();
        }
        process.setWorkingDirectory(m_workingDirectory);
        process.start(QLatin1String("hg"), args);
        process.waitForFinished();
        
        if (process.exitCode() == 0 && process.exitStatus() == QProcess::NormalExit) {
            KDialog::done(r);
        }
        else {
            KMessageBox::error(this, i18nc("error message", "Error creating repository!"));
        }
    }
    else {
        KDialog::done(r);
    }
}
开发者ID:ShermanHuang,项目名称:kdesdk,代码行数:24,代码来源:createdialog.cpp


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