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


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

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


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

示例1: performPatchApplication

static inline bool performPatchApplication(const QString &patch, const QString &workingDirectory,
                                           bool reverse = false)
{
    QProcess process;
    process.setProgram(PATCH);
    process.setWorkingDirectory(workingDirectory);
    process.setStandardInputFile(patch);
    QStringList arguments;
    arguments << P1_FLAG << DRY_RUN_FLAG;
    if (!reverse) {
        arguments << T_FLAG << N_FLAG;
    } else {
        arguments << F_FLAG << R_FLAG;
    }
    process.setArguments(arguments);
    process.start();
    process.waitForFinished(-1);
    if (process.exitCode() != 0) {
        return false;
    }

    arguments.clear();
    arguments << P1_FLAG;
    if (!reverse) {
        arguments << T_FLAG << N_FLAG;
    } else {
        arguments << F_FLAG << R_FLAG;
    }
    process.setArguments(arguments);
    process.start();
    process.waitForFinished(-1);
    return (process.exitCode() == 0);
}
开发者ID:MFaroTusino,项目名称:patchmanager,代码行数:33,代码来源:patchmanagerobject.cpp

示例2: testZot

void TestZot::testZot()
{
    QDir bin(QCoreApplication::applicationDirPath());
    QVERIFY(bin.exists());

    QDir examples(bin.path() + "/../../examples");
    QVERIFY(examples.exists());

    QProcess zot;
    zot.setProgram(bin.path() + QDir::separator() + "zot");

    // reverser
    QStringList args = QStringList()
      << "--file"
      << examples.path() + "/reverser.zot"
      << "--input"
      << "111000";

    zot.setArguments(args);
    zot.start();
    QVERIFY(zot.waitForFinished());
    QCOMPARE(zot.exitStatus(), QProcess::NormalExit);
    QCOMPARE(zot.exitCode(), 0);
    QCOMPARE(zot.state(), QProcess::NotRunning);
    QCOMPARE(zot.readAll(), QByteArray("000111\n"));
}
开发者ID:manyoso,项目名称:zot,代码行数:26,代码来源:testzot.cpp

示例3: QString

Calamares::JobResult
ClearMountsJob::exec()
{
    QStringList goodNews;

    QString deviceName = m_device->deviceNode().split( '/' ).last();

    QProcess process;
    process.setProgram( "sh" );
    process.setArguments( {
                              "-c",
                              QString( "echo $(awk '{print $4}' /proc/partitions | sed -e '/name/d' -e '/^$/d' -e '/[1-9]/!d' | grep %1)" )
                                      .arg( deviceName )
                          } );
    process.start();
    process.waitForFinished();

    QString partitions = process.readAllStandardOutput();
    QStringList partitionsList = partitions.simplified().split( ' ' );

    // Build a list of partitions of type 82 (Linux swap / Solaris).
    // We then need to clear them just in case they contain something resumable from a
    // previous suspend-to-disk.
    QStringList swapPartitions;
    process.start( "sfdisk", { "-d", m_device->deviceNode() } );
    process.waitForFinished();
    // Sample output:
    //    % sudo sfdisk -d /dev/sda
    //    label: dos
    //    label-id: 0x000ced89
    //    device: /dev/sda
    //    unit: sectors

    //    /dev/sda1 : start=          63, size=    29329345, type=83, bootable
    //    /dev/sda2 : start=    29331456, size=     2125824, type=82

    swapPartitions = QString::fromLocal8Bit( process.readAllStandardOutput() )
                        .split( '\n' );
    swapPartitions = swapPartitions.filter( "type=82" );
    for ( QStringList::iterator it = swapPartitions.begin();
          it != swapPartitions.end(); ++it )
    {
        *it = (*it).simplified().split( ' ' ).first();
    }

    // First we umount all LVM logical volumes we can find
    process.start( "lvscan", { "-a" } );
    process.waitForFinished();
    if ( process.exitCode() == 0 ) //means LVM2 tools are installed
    {
        QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
        foreach ( const QString& lvscanLine, lvscanLines )
        {
            QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column
            lvPath = lvPath.replace( '\'', "" );

            QString news = tryUmount( lvPath );
            if ( !news.isEmpty() )
                goodNews.append( news );
        }
开发者ID:rajuvindane,项目名称:calamares-1,代码行数:60,代码来源:ClearMountsJob.cpp

示例4: runApp

static Result runApp(const QString &execPath, const QStringList &args)
{
//   QString outPipePath = FS::TmpFilePath("pipeOut");
    QProcess app;
    app.setProgram(execPath);
    app.setArguments(args);
    app.start();

    if (!app.waitForStarted()) {
        qWarning() << "Cmd Exec Failed:" << app.errorString();
        return Result(Result::Failed, app.errorString(), "", app.program());
    }

    if (!app.waitForFinished(-1)) {
        qWarning() << "waitForFinished Failed:" << app.errorString();
        return Result(Result::Failed, app.errorString(), "", app.program());
    }

    auto standardError = app.readAllStandardError();

    if (QProcess::NormalExit != app.exitStatus()) {
        qWarning() << "exitStatus error:" << app.exitStatus() << standardError << app.program();
        return Result(Result::Failed, standardError, "", app.program());
    }

    if (0 != app.exitCode()) {
        qWarning() << "exitCode error:" << app.exitCode() << standardError << app.program();
        return Result(Result::Failed, standardError, "", app.program());
    }

    Result rest(Result::Success, standardError, app.readAllStandardOutput());
    return rest;
}
开发者ID:linuxdeepin,项目名称:deepin-boot-maker,代码行数:33,代码来源:Cmd.cpp

示例5: recursiveFileOpener

void recursiveFileOpener(QFileInfo file, int & failures, int & total, int & timeOut, int argc, char *argv[])
{
	const QString jaspExtension(".jasp");

	//std::cout << "recursiveFileOpener in " << file.absoluteFilePath().toStdString() << std::endl;

	if(file.isDir())
	{
		//std::cout << "it is a directory and " << (file.exists() ? "exists" : "does not exist") << std::endl;

		QDir dir(file.absoluteFilePath());

		//std::cout << "QDir dir: " << dir.path().toStdString() << " has " << files.size() << " subfiles!" << std::endl;

		for(QFileInfo subFile : dir.entryInfoList(QDir::Filter::NoDotAndDotDot | QDir::Files | QDir::Dirs))
			recursiveFileOpener(subFile, failures, total, timeOut, argc, argv);

	}
	else if(file.isFile())
	{
		//std::cout << "it is a file" << std::endl;

		if(file.absoluteFilePath().indexOf(jaspExtension) == file.absoluteFilePath().size() - jaspExtension.size())
		{
			//std::cout << "it has the .jasp extension so we will start JASP" << std::endl;
#ifndef SEPARATE_PROCESS
			std::cout << "Found a JASP file (" << file.absoluteFilePath().toStdString() << ") going to start JASP" << std::endl;
#endif

			int result = 1;

			try{
#ifdef SEPARATE_PROCESS
				QProcess subJasp;
				subJasp.setProgram(argv[0]);
				subJasp.setArguments({file.absoluteFilePath(), "--unitTest", QString::fromStdString("--timeOut="+std::to_string(timeOut)), "-platform", "minimal" });
				subJasp.start();

				subJasp.waitForFinished((timeOut * 60000) + 10000);

				std::cerr << subJasp.readAllStandardError().toStdString() << std::endl;

				result = subJasp.exitCode();
#else
				//This seems to crash for some reason
				result = Application(argc, argv, file.absoluteFilePath(), true, timeOut).exec();
#endif
			}
			catch(...) { result = -1; }


			std::cout << "JASP file " << file.absoluteFilePath().toStdString() << (result == 0 ? " succeeded!" : " failed!") << std::endl;

			if(result != 0)
				failures++;

			total++;
		}
	}
}
开发者ID:jasp-stats,项目名称:jasp-desktop,代码行数:60,代码来源:main.cpp

示例6: Window

 Window() {
    m_layout.addWidget(&m_button);
    m_process.setProgram("sleep");
    m_process.setArguments({"5"});
    connect(&m_button, &QPushButton::clicked, &m_process, [=]{ m_process.start(); });
    connect(&m_process, (void(QProcess::*)(int))&QProcess::finished, [=]{ m_box.show(); });
 }
开发者ID:KubaO,项目名称:stackoverflown,代码行数:7,代码来源:main.cpp

示例7: setupClicked

void MainWidget::setupClicked()
{
	if (ui->setupName->text().isEmpty())
	{
		return;
	}
	QProcess *process = createProcess();
	QStringList args;
	args << "setup";
	if (!ui->setupNem->text().isEmpty())
	{
		args << "--nem" << ui->setupNem->text();
	}
	if (!ui->setupCurse->text().isEmpty())
	{
		args << "--curse" << ui->setupCurse->text();
	}
	if (!ui->setupServer->text().isEmpty())
	{
		args << "--server" << ui->setupServer->text();
	}
	args << ui->setupName->text();
	process->setArguments(args);
	startProcess(process);
}
开发者ID:02JanDal,项目名称:QuickModGenerator,代码行数:25,代码来源:MainWidget.cpp

示例8: openMailComposer

void KaduExtInfo::openMailComposer(const QString &link)
{
    kdebugf();
    QProcess *browser;
    QStringList args;
    QString mail = link;

    QString mailComposer = mailProgram;
    if (mailProgram.isEmpty())
    {
        /*QMessageBox::warning(0, qApp->translate("@default", QT_TR_NOOP("WWW error")),
            qApp->translate("@default", QT_TR_NOOP("Web browser was not specified. Visit the configuration section")));*/
        kdebugmf(KDEBUG_INFO, "Mail composer NOT specified.\n");
        return;
    }
    if (!mailComposer.contains("%1"))
        mailComposer.append(" \"%1\"");

    mail.replace("mailto:","");
    mailComposer.replace("%1", unicode2latinUrl(mail));

    args=toStringList("sh", "-c", mailComposer);

    CONST_FOREACH(i, args)
        kdebugmf(KDEBUG_INFO, "%s\n", (*i).local8Bit().data());
    browser = new QProcess(qApp);
    browser->setArguments(args);
    QObject::connect(browser, SIGNAL(processExited()), browser, SLOT(deleteLater()));

    if (!browser->start())
        QMessageBox::critical(0, tr("Mail error"), tr("Could not spawn Mail composer process. Check if the Mail program is functional"));

    kdebugf2();
}
开发者ID:BackupTheBerlios,项目名称:kadu-ext-info,代码行数:34,代码来源:ext_general.cpp

示例9: verifyClicked

void MainWidget::verifyClicked()
{
	if (files().isEmpty())
	{
		return;
	}
	QProcess *process = createProcess();
	process->setArguments(QStringList() << "verify" << files());
	startProcess(process);
}
开发者ID:02JanDal,项目名称:QuickModGenerator,代码行数:10,代码来源:MainWidget.cpp

示例10: edit

bool CodeManager::edit()
{
    QProcess *proc = new QProcess();
    QStringList args
        = QStringList::split(' ', Settings::instance()->editorCmd());
    args.append(filename());

    proc->setArguments(args);
    proc->setWorkingDirectory(QDir(sourcePath()));

    return proc->launch("");
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:12,代码来源:codemanager.cpp

示例11: setPassword

void AccountsWorker::setPassword(User *user, const QString &oldpwd, const QString &passwd)
{
    QProcess process;
    process.setProgram("passwd");
    process.setArguments(QStringList() << user->name());
    process.start();
    process.write(QString("%1\n%2\n%3").arg(oldpwd).arg(passwd).arg(passwd).toLatin1());
    process.closeWriteChannel();
    process.waitForFinished();

    qDebug() << Q_FUNC_INFO << process.readAllStandardError() << process.readAllStandardOutput();

    Q_EMIT user->passwordModifyFinished(process.exitCode());
}
开发者ID:linuxdeepin,项目名称:dde-control-center,代码行数:14,代码来源:accountsworker.cpp

示例12: installDependency

bool PackageJobThread::installDependency(const QUrl &destUrl)
{
    auto handler = resolveHandler(destUrl.scheme());
    if (handler.isEmpty())
        return false;

    QProcess process;
    process.setProgram(handler);
    process.setArguments({ destUrl.toString() });
    process.setProcessChannelMode(QProcess::ForwardedChannels);
    process.start();
    process.waitForFinished();

    return process.exitCode() == 0;
}
开发者ID:KDE,项目名称:kpackage,代码行数:15,代码来源:packagejobthread.cpp

示例13: openLocation

/**
  * Open the location of the path, launch a system file browser to the given directory path. If the path is a file then it will open it's containing directory and select it.
  *
  * An other on Windows is to use 'SHOpenFolderAndSelectItems(..)'.
  */
void Utils::openLocation(const QString& path)
{
#ifdef Q_OS_WIN32
    QProcess explorer;
    if (!QFileInfo(path).isDir())
        explorer.setArguments(QStringList() << "/select,");
    explorer.setNativeArguments("\"" + QDir::toNativeSeparators(path) + "\"");
    explorer.setProgram("explorer");
    explorer.start();
    explorer.waitForFinished(5000);
#else
    QFileInfo fileInfo(path);
    const QString dirPath = fileInfo.isDir() ? path : fileInfo.absolutePath();
    QDesktopServices::openUrl(QUrl("file:///" + dirPath, QUrl::TolerantMode));
#endif
}
开发者ID:Ummon,项目名称:D-LAN,代码行数:21,代码来源:Utils.cpp

示例14: createIndexClicked

void MainWidget::createIndexClicked()
{
	if (files().isEmpty())
	{
		return;
	}
	QProcess *process = createProcess();
	QStringList args;
	args << "create-index";
	if (!ui->createIndexBaseUrl->text().isEmpty())
	{
		args << "--base" << ui->createIndexBaseUrl->text();
	}
	args << files();
	process->setArguments(args);
	startProcess(process);
}
开发者ID:02JanDal,项目名称:QuickModGenerator,代码行数:17,代码来源:MainWidget.cpp

示例15: updateClicked

void MainWidget::updateClicked()
{
	if (files().isEmpty())
	{
		return;
	}
	QProcess *process = createProcess();
	QStringList args;
	args << "update";
	if (ui->updateNetworkBtn->isChecked())
	{
		args << "--no-network";
	}
	args << files();
	process->setArguments(args);
	startProcess(process);
}
开发者ID:02JanDal,项目名称:QuickModGenerator,代码行数:17,代码来源:MainWidget.cpp


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