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


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

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


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

示例1: report

Calamares::JobResult
CreatePartitionTableJob::exec()
{
    Report report( 0 );
    QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() );

    CoreBackend* backend = CoreBackendManager::self()->backend();
    QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) );
    if ( !backendDevice.data() )
    {
        return Calamares::JobResult::error(
                   message,
                   tr( "Could not open device %1." ).arg( m_device->deviceNode() )
               );
    }

    QScopedPointer< PartitionTable > table( createTable() );
    cDebug() << "Creating new partition table of type" << table->typeName()
             << ", uncommitted yet:\n" << table;

    QProcess lsblk;
    lsblk.setProgram( "lsblk" );
    lsblk.setProcessChannelMode( QProcess::MergedChannels );
    lsblk.start();
    lsblk.waitForFinished();
    cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput();

    QProcess mount;
    mount.setProgram( "mount" );
    mount.setProcessChannelMode( QProcess::MergedChannels );
    mount.start();
    mount.waitForFinished();
    cDebug() << "mount:\n" << mount.readAllStandardOutput();

    bool ok = backendDevice->createPartitionTable( report, *table );
    if ( !ok )
    {
        return Calamares::JobResult::error(
                    message,
                    QString( "Text: %1\nCommand: %2\nOutput: %3\nStatus: %4" )
                        .arg( report.toText() )
                        .arg( report.command() )
                        .arg( report.output() )
                        .arg( report.status() )
               );
    }

    return Calamares::JobResult::ok();
}
开发者ID:Rezesius,项目名称:calamares,代码行数:49,代码来源:CreatePartitionTableJob.cpp

示例2: exec

QStringList MainWindow::exec(const QString &pExe,
							 const QString &pDir)
{
	QProcess lProcess;
	lProcess.setProcessChannelMode(QProcess::MergedChannels);

	if(!pDir.isEmpty())
	{
		lProcess.setWorkingDirectory(pDir);
	}
	lProcess.start(pExe);

	if(!lProcess.waitForFinished())
	{
		return QStringList() << lProcess.errorString();
	}

	//! TODO: find a better way to do this!
	QList<QByteArray> lTempLines = lProcess.readAll().split('\n');
	QStringList lStringList;
	for(int i=0;i<lTempLines.size();i++)
	{
		QString lLine(lTempLines[i]);
		if(lLine.isEmpty())
			continue;

		lStringList.append(lLine);
	}

	return lStringList;
}
开发者ID:icebreaker,项目名称:sexygrep,代码行数:31,代码来源:mainwindow.cpp

示例3: testPass

void MainWindow::testPass()
{

  QString program = "sudo";
  QStringList arguments;
  arguments << "-S";
  arguments << "-k";
  arguments << "true";

  QProcess *tP = new QProcess(this);
  tP->setProcessChannelMode(QProcess::MergedChannels);
  tP->start(program, arguments);
  tP->write(passwordLineEdit->text().toLatin1() + "\n");
  tP->write(passwordLineEdit->text().toLatin1() + "\n");
  tP->write(passwordLineEdit->text().toLatin1() + "\n");
  while(tP->state() == QProcess::Starting || tP->state() == QProcess::Running ) {
     tP->waitForFinished(500);
     QCoreApplication::processEvents();
  }
  if ( tP->exitCode() != 0 )
  {
     QString tmp;
     tmp.setNum(tries-1);
     labelBadPW->setText(tr("Invalid Password! Tries Left: %1").arg(tmp) );
     tries--;
     if ( tries == 0 )
       exit(1);
     passwordLineEdit->setText("");
  } else {
     startSudo();
  }
}
开发者ID:rapenne-s,项目名称:pcbsd,代码行数:32,代码来源:mainwindow.cpp

示例4: datasetInfo

bool LPBackend::datasetInfo(QString dataset, int& time, int& numToKeep){
  QString cmd = "lpreserver listcron";
  //Need output, so run this in a QProcess
  QProcess *proc = new QProcess;
  proc->setProcessChannelMode(QProcess::MergedChannels);
  proc->start(cmd);
  proc->waitForFinished();
  QStringList out = QString(proc->readAllStandardOutput()).split("\n");	
  delete proc;
  //Now process the output
  bool ok = false;
  for(int i=0; i<out.length(); i++){
    if(out[i].section(" - ",0,0).simplified() == dataset){
      //Get time schedule (in integer format)
      QString sch = out[i].section(" - ",1,1).simplified();
      if(sch.startsWith("[email protected]")){ time = sch.section("@",1,1).simplified().toInt(); }
      else if(sch=="5min"){time = -5;}
      else if(sch=="10min"){time = -10;}
      else if(sch=="30min"){time = -30;}
      else{ time = -60; } //hourly
      //Get total snapshots
      numToKeep = out[i].section("- total:",1,1).simplified().toInt();
      ok=true;
      break;
    }
  }
  //qDebug() << "lpreserver cronsnap:\n" << out << QString::number(time) << QString::number(numToKeep);
   
  return ok;
}
开发者ID:KdeOs,项目名称:pcbsd,代码行数:30,代码来源:LPBackend.cpp

示例5: replicationInfo

bool LPBackend::replicationInfo(QString dataset, QString& remotehost, QString& user, int& port, QString& remotedataset, int& time){
  QString cmd = "lpreserver replicate list";
  //Need output, so run this in a QProcess
  QProcess *proc = new QProcess;
  proc->setProcessChannelMode(QProcess::MergedChannels);
  proc->start(cmd);
  proc->waitForFinished();
  QStringList out = QString(proc->readAllStandardOutput()).split("\n");	
  delete proc;
  //Now process the output
  bool ok = false;
  for(int i=0; i<out.length(); i++){
    if(out[i].contains("->") && out[i].startsWith(dataset)){
      QString data = out[i].section("->",1,1);
      user = data.section("@",0,0);
      remotehost = data.section("@",1,1).section("[",0,0);
      port = data.section("[",1,1).section("]",0,0).toInt();
      remotedataset = data.section(":",1,1).section(" Time",0,0);
      QString synchro = data.section("Time:",1,1).simplified();
	if(synchro == "sync"){ time = -1; }
	else{ time = synchro.toInt(); }
      ok = true;
      break;
    }
  }	  
   
  return ok;
}
开发者ID:KdeOs,项目名称:pcbsd,代码行数:28,代码来源:LPBackend.cpp

示例6: retrieveDevices

DeviceList DeviceInfo::retrieveDevices(DeviceType type) {
	qDebug("DeviceInfo::retrieveDevices: %d", type);
	
	DeviceList l;
	QRegExp rx_device("^(\\d+): (.*)");
	
	if (QFile::exists("dxlist.exe")) {
		QProcess p;
		p.setProcessChannelMode( QProcess::MergedChannels );
		QStringList arg;
		if (type == Sound) arg << "-s"; else arg << "-d";
		p.start("dxlist", arg);

		if (p.waitForFinished()) {
			QByteArray line;
			while (p.canReadLine()) {
				line = p.readLine().trimmed();
				qDebug("DeviceInfo::retrieveDevices: '%s'", line.constData());
				if ( rx_device.indexIn(line) > -1 ) {
					int id = rx_device.cap(1).toInt();
					QString desc = rx_device.cap(2);
					qDebug("DeviceInfo::retrieveDevices: found device: '%d' '%s'", id, desc.toUtf8().constData());
					l.append( DeviceData(id, desc) );
				}
			}
		}
	}
	
	return l;
}
开发者ID:dradetsky,项目名称:smplayer-mirror,代码行数:30,代码来源:deviceinfo.cpp

示例7: 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();

#if !defined(MIKTEX)
	// 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"));
#endif

	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:MiKTeX,项目名称:miktex,代码行数:60,代码来源:Engine.cpp

示例8: launch

void ProcessLauncherHelper::launch(WebKit::ProcessLauncher* launcher)
{
    QString applicationPath = "%1 %2";

    if (QFile::exists(QCoreApplication::applicationDirPath() + "/QtWebProcess")) {
        applicationPath = applicationPath.arg(QCoreApplication::applicationDirPath() + "/QtWebProcess");
    } else {
        applicationPath = applicationPath.arg("QtWebProcess");
    }

    QString program(applicationPath.arg(m_server.serverName()));

    QProcess* webProcess = new QProcess();
    webProcess->setProcessChannelMode(QProcess::ForwardedChannels);
    webProcess->start(program);

    if (!webProcess->waitForStarted()) {
        qDebug() << "Failed to start" << program;
        ASSERT_NOT_REACHED();
        delete webProcess;
        return;
    }

    setpriority(PRIO_PROCESS, webProcess->pid(), 10);

    m_items.append(WorkItem::create(launcher, &WebKit::ProcessLauncher::didFinishLaunchingProcess, webProcess, m_server.serverName()).leakPtr());
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例9: RealStart

void TCPBase::RealStart()
{
    connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    IPCSocket = 0;

#ifdef HWLIBRARY
    QThread *thread = new QThread;
    EngineInstance *instance = new EngineInstance;
    instance->port = IPCServer->serverPort();

    instance->moveToThread(thread);

    connect(thread, SIGNAL(started()), instance, SLOT(start(void)));
    connect(instance, SIGNAL(finished()), thread, SLOT(quit()));
    connect(instance, SIGNAL(finished()), instance, SLOT(deleteLater()));
    connect(instance, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();
#else
    QProcess * process;
    process = new QProcess();
    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError)));
    QStringList arguments=getArguments();

#ifdef QT_DEBUG
    // redirect everything written on stdout/stderr
    process->setProcessChannelMode(QProcess::ForwardedChannels);
#endif

    process->start(bindir->absolutePath() + "/hwengine", arguments);
#endif
    m_hasStarted = true;
}
开发者ID:akzfowl,项目名称:hw,代码行数:32,代码来源:tcpBase.cpp

示例10: ProcessRun

inline QStringList ProcessRun(QString cmd, QStringList args){
  //Assemble outputs
  QStringList out; out << "1" << ""; //error code, string output
  QProcess proc;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  proc.setProcessEnvironment(env);
  proc.setProcessChannelMode(QProcess::MergedChannels);
  if(args.isEmpty()){
    proc.start(cmd, QIODevice::ReadOnly);
  }else{
    proc.start(cmd,args ,QIODevice::ReadOnly);	  
  }
  QString info;
  while(!proc.waitForFinished(1000)){
    if(proc.state() == QProcess::NotRunning){ break; } //somehow missed the finished signal
    QString tmp = proc.readAllStandardOutput();
    if(tmp.isEmpty()){ proc.terminate(); }
    else{ info.append(tmp); }
  }
  out[0] = QString::number(proc.exitCode());
  out[1] = info+QString(proc.readAllStandardOutput());
  return out;	
}
开发者ID:Nanolx,项目名称:lumina,代码行数:25,代码来源:LUtils.cpp

示例11: symbol_list_file

void powotsimulator::symbol_list_file(QString *filepath, QStringList *symbol_list){
    QStringList symbol_dump;
    QString cmd;
    cmd = symbollist_cmd + *filepath;
    qDebug()<<"(powotsimulator) symbollist cmd:"<<cmd;

    QProcess terminal;
    terminal.setProcessChannelMode(QProcess::MergedChannels);
    terminal.start(cmd);
    terminal.waitForFinished(-1);
    QByteArray temp = terminal.readAllStandardOutput();
    convert_bytearray_stringlist(&temp, &symbol_dump);

    if(symbol_dump.isEmpty()){
        err_message.display_error(SYMBOLLIST_FAILED);
        qDebug()<<"(powotsimulator) Aborting ...";
        exit(-1);
    }

    for(int i = 0; i < symbol_dump.size(); i++){
        *symbol_list << symbol_dump.at(i).section(' ', 2, 2);
    }

    /*qDebug()<<"SYMBOLS:";
    for(int i = 0; i < symbol_list->size(); i++)
    {
        qDebug()<<"symbollist_file: ***"<<symbol_list->at(i)<<" size: "<<symbol_list->at(i).size();
    }*/
}
开发者ID:LubomirBogdanov,项目名称:powot_simulator_v2,代码行数:29,代码来源:symbol_list_file.cpp

示例12: partitionDrive

bool DriveFormatThread::partitionDrive()
{
    QByteArray partitionTable;

    if (_reformatBoot)
        partitionTable = "2048,129024,0E\n"; /* 63 MB FAT partition LBA */
//        partitionTable = "0,128,6\n"; /* 64 MB FAT partition */

    partitionTable += "131072,,L\n"; /* Linux partition with all remaining space */
    partitionTable += "0,0\n";
    partitionTable += "0,0\n";
    if (!_reformatBoot)
        partitionTable += "0,0\n";

    //QString cmd = QString("/sbin/sfdisk -H 32 -S 32 /dev/")+_dev;
    QString cmd = QString("/sbin/sfdisk -H 255 -S 63 -u S /dev/")+_dev;
    QProcess proc;
    proc.setProcessChannelMode(proc.MergedChannels);
    proc.start(cmd);
    proc.write(partitionTable);
    proc.closeWriteChannel();
    proc.waitForFinished(-1);
    //qDebug() << "partitioning" << cmd;
    //qDebug() << partitionTable;

    return proc.exitCode() == 0;
}
开发者ID:CNCBASHER,项目名称:berryboot,代码行数:27,代码来源:driveformatthread.cpp

示例13: QObject

HacServer::HacServer(QObject *parent)
: QObject(parent)
{
	qDebug() << "HacServer::HacServer";
	// init qws server
	server = QWSServer::instance();
	QScreen *screen = QScreen::instance();
	server->setMaxWindowRect(QRect(WINDOW_X, WINDOW_Y, WINDOW_W, WINDOW_H));

	// init status bar 
	statusBar = new StatusBar;
	connect(statusBar, SIGNAL(homeClicked()), this, SLOT(OnHomeClicked()));
	connect(statusBar, SIGNAL(backClicked()), this, SLOT(OnBackClicked()));
	connect(statusBar, SIGNAL(clockClicked()), this, SLOT(OnClockClicked()));
	statusBar->setGeometry(STATUSBAR_X, STATUSBAR_Y, STATUSBAR_W, STATUSBAR_H);
	statusBar->show();

	// init auto start applications


    QProcess *myApp = new QProcess;
    myApp->setProcessChannelMode(QProcess::ForwardedChannels);
	myApp->start(APP_HAC01_BIN);
	myApp->waitForStarted();
}
开发者ID:etop-wesley,项目名称:hac,代码行数:25,代码来源:hacserver.cpp

示例14: xvAdaptors

DeviceList DeviceInfo::xvAdaptors()
{
    qDebug("DeviceInfo::xvAdaptors");

    DeviceList l;
    QRegExp rx_device("^.*Adaptor #([0-9]+): \"(.*)\"");

    QProcess p;
    p.setProcessChannelMode(QProcess::MergedChannels);
    p.setEnvironment(QProcess::systemEnvironment() << "LC_ALL=C");
    p.start("xvinfo");

    if (p.waitForFinished()) {
        QByteArray line;

        while (p.canReadLine()) {
            line = p.readLine();
            qDebug("DeviceInfo::xvAdaptors: '%s'", line.constData());

            if (rx_device.indexIn(line) > -1) {
                QString id = rx_device.cap(1);
                QString desc = rx_device.cap(2);
                qDebug("DeviceInfo::xvAdaptors: found adaptor: '%s' '%s'", id.toUtf8().constData(), desc.toUtf8().constData());
                l.append(DeviceData(id, desc));
            }
        }
    } else {
        qDebug("DeviceInfo::xvAdaptors: could not start xvinfo, error %d", p.error());
    }

    return l;
}
开发者ID:JackieKu,项目名称:SMPlayer2,代码行数:32,代码来源:deviceinfo.cpp

示例15: qtCoreFromLsof

QString ProbeABIDetector::qtCoreFromLsof(qint64 pid) const
{
    QString lsofExe;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    lsofExe = QStandardPaths::findExecutable(QStringLiteral("lsof"));
    // on OSX it's in sbin, which usually but not always is in PATH...
    if (lsofExe.isEmpty())
        lsofExe = QStandardPaths::findExecutable(QStringLiteral("lsof"),
                                                 QStringList() << QStringLiteral(
                                                     "/usr/sbin") << QStringLiteral("/sbin"));
#endif
    if (lsofExe.isEmpty())
        lsofExe = QStringLiteral("lsof"); // maybe QProcess has more luck

    QProcess proc;
    proc.setProcessChannelMode(QProcess::SeparateChannels);
    proc.setReadChannel(QProcess::StandardOutput);
    proc.start(lsofExe, QStringList() << QStringLiteral("-Fn") << QStringLiteral(
                   "-n") << QStringLiteral("-p") << QString::number(pid));
    proc.waitForFinished();

    forever {
        const QByteArray line = proc.readLine();
        if (line.isEmpty())
            break;

        if (containsQtCore(line))
            return QString::fromLocal8Bit(line.mid(1).trimmed()); // strip the field identifier
    }

    return QString();
}
开发者ID:giucam,项目名称:GammaRay,代码行数:32,代码来源:probeabidetector.cpp


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