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


C++ QProcessEnvironment类代码示例

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


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

示例1: QString

/**
 * @brief KernelModel::getRunningKernel get running kernel in the system
 * @return string with the version of running kernel
 */
QString
KernelModel::getRunningKernel() const
{
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert( "LANG", "C" );
    env.insert( "LC_MESSAGES", "C" );
    env.insert( "LC_ALL", "C" );

    QProcess uname;
    uname.setProcessEnvironment( env );

    uname.start( "uname", QStringList() << "-r" );
    uname.waitForFinished();
    QString result = uname.readAllStandardOutput();
    uname.close();
    QStringList aux = result.split( ".", QString::SkipEmptyParts );
    return QString( "linux%1%2" ).arg( aux.at( 0 ) ).arg( aux.at( 1 ) );
}
开发者ID:Jacobtey,项目名称:manjaro-settings-manager-wi,代码行数:22,代码来源:KernelModel.cpp

示例2: result

/*
 * Performs a pacman query
 */
QByteArray UnixCommand::performQuery(const QStringList args)
{
  QByteArray result("");
  QProcess pacman;

  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  env.insert("LC_ALL", "C");
  pacman.setProcessEnvironment(env);

  pacman.start("pacman", args);
  pacman.waitForFinished();
  result = pacman.readAllStandardOutput();
  pacman.close();

  return result;
}
开发者ID:LAC1213,项目名称:octopi,代码行数:21,代码来源:unixcommand.cpp

示例3: runCommand

/*
 * Executes given command and returns the StandardError Output.
 */
QString UnixCommand::runCommand(const QString& commandToRun)
{
  QProcess proc;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.remove("LANG");
  env.remove("LC_MESSAGES");
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  proc.setProcessEnvironment(env);
  proc.start(commandToRun);
  proc.waitForStarted();
  proc.waitForFinished(-1);

  QString res = proc.readAllStandardError();
  proc.close();

  return res;
}
开发者ID:LAC1213,项目名称:octopi,代码行数:21,代码来源:unixcommand.cpp

示例4: m_app

App::App(QCoreApplication *application, const QString &sessionName)
    : m_app(application)
    , m_exitCode(0)
    , m_closed(false)
{
    QString session("copyq");
    if ( !sessionName.isEmpty() ) {
        session += "-" + sessionName;
        m_app->setProperty( "CopyQ_session_name", QVariant(sessionName) );
    }

#ifdef HAS_TESTS
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    if ( env.value("COPYQ_TESTING") == "1" )
        session += ".test";
#endif

    QCoreApplication::setOrganizationName(session);
    QCoreApplication::setApplicationName(session);

    const QString locale = QLocale::system().name();
    QTranslator *translator = new QTranslator(m_app.data());
    translator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    QCoreApplication::installTranslator(translator);

    translator = new QTranslator(m_app.data());
    translator->load("copyq_" + locale, ":/translations");
    QCoreApplication::installTranslator(translator);

#ifdef Q_OS_UNIX
    // Safely quit application on TERM and HUP signals.
    struct sigaction sigact;

    sigact.sa_handler = ::exitSignalHandler;
    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags = 0;
    sigact.sa_flags |= SA_RESTART;

    if ( sigaction(SIGHUP, &sigact, 0) > 0
         || sigaction(SIGINT, &sigact, 0) > 0
         || sigaction(SIGTERM, &sigact, 0) > 0 )
        log( QString("sigaction() failed!"), LogError );
#endif
}
开发者ID:rygwdn,项目名称:CopyQ,代码行数:44,代码来源:app.cpp

示例5: writeSettings

void MainWindow::on_buttonBox_accepted() {
  writeSettings();

  QSettings settings(QSettings::IniFormat, QSettings::UserScope,
                     Organization, ProjectName);
  QString ocrCmd;

  if (settings.contains("OCR/program"))
    ocrCmd = settings.value("OCR/program").toString();

  // TODO(zdenop): check for missing setting or empty string

  QStringList args;

  QString in = ui->lineEditIn->text();
  args << in;
  QString out = ui->lineEditOut->text();
  out = out.replace(".txt", "").replace(".html", "");
  args << out;

  QString lang = ui->comboBoxLang->itemData(
                   ui->comboBoxLang->currentIndex()).toString();
  args << "-l" << lang;

  if (ui->comboBoxPSM->isEnabled()) {
    int PSM = ui->comboBoxPSM->currentIndex();
    args  << "-psm" << QString::number(PSM);
  }

  if (ui->comboBoxForm->currentIndex() == 1) {
    args << "hocr";
  }

  if (!settings.value("OCR/sys_prefix").toBool()) {
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TESSDATA_PREFIX", settings.value("OCR/prefix").toString());
    process.setProcessEnvironment(env);
    }

  ui->tb_Log->appendHtml(tr("OCR program started..."));
  ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
  process.start(ocrCmd, args);
}
开发者ID:jldm231,项目名称:tesseract-ocr-qt4gui,代码行数:43,代码来源:mainwindow.cpp

示例6: main

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    // Try to get all of the env variables here
    QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();

    QStringList keys = environment.keys();

    QList<QObject*> dataList;

    foreach (QString key, keys) {
        qDebug() << "key: " << key;

        QString value = environment.value(key);
        qDebug() << "value: " << value;

        dataList.append(new DataObject(key, value));
    }
开发者ID:UbuntuChina,项目名称:runtime,代码行数:19,代码来源:main.cpp

示例7: qDebug

void QvkPulse::pulseUnloadModule()
{
  //qDebug( " " );
  qDebug() << "[vokoscreen] ---Begin Pulse unload Module---";
  QProcess Process;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "c");
  Process.setProcessEnvironment(env);
  Process.start( "pactl list" );
  Process.waitForFinished();
  QString output = Process.readAllStandardOutput();
  Process.close();
  
  QStringList list = output.split( "\n" );
  
  QStringList modulNumberList;
  QString str;
  QString strLog;
  for ( int i = 0; i < list.count(); i++ )
  {
     str = list[ i ];
     if ( str.contains("vokoscreenMix", Qt::CaseInsensitive) )
     {
       str = list[ i - 2 ];
       if ( str.contains("Module", Qt::CaseInsensitive) )
       {
	 str.replace("Module #", "");
	 str.replace("\n", "");
	 modulNumberList.insert ( 0, str );
       }
     }
  }
  
  for ( int i = 0; i < modulNumberList.count(); i++ )
  {
    Process.start("pactl unload-module " + modulNumberList[ i ] );
    Process.waitForFinished();
    Process.close();
    qDebug() << "[vokoscreen] pactl unload-module number" << modulNumberList[ i ] ;
  }
  qDebug() << "[vokoscreen] ---End Pulse unload Module---";
  qDebug( " " );
}
开发者ID:afiestas,项目名称:vokoscreen,代码行数:43,代码来源:QvkPulse.cpp

示例8: launchProcess

bool ProcessInjector::launchProcess(const QStringList& programAndArgs, const QProcessEnvironment& env)
{
    InteractiveProcess proc;
    proc.setProcessEnvironment(env);
    proc.setProcessChannelMode(QProcess::ForwardedChannels);

    QStringList args = programAndArgs;

    if (!env.value("GAMMARAY_TARGET_WRAPPER").isEmpty()) {
        const QString fullWrapperCmd = env.value("GAMMARAY_TARGET_WRAPPER");
        // ### TODO properly handle quoted arguments!
        QStringList newArgs = fullWrapperCmd.split(' ');
        newArgs += args;
        args = newArgs;
        qDebug() << "Launching with target wrapper:" << args;
    } else if (env.value("GAMMARAY_GDB").toInt()) {
        QStringList newArgs;
        newArgs << "gdb";
#ifndef Q_OS_MAC
        newArgs << "--eval-command" << "run";
#endif
        newArgs << "--args";
        newArgs += args;
        args = newArgs;
    }

    const QString program = args.takeFirst();
    proc.start(program, args);
    proc.waitForFinished(-1);

    mExitCode = proc.exitCode();
    mProcessError = proc.error();
    mExitStatus = proc.exitStatus();
    mErrorString = proc.errorString();

    if (mProcessError == QProcess::FailedToStart) {
        mErrorString.prepend(QString("Could not start '%1': ").arg(program));
    }

    return mExitCode == EXIT_SUCCESS && mExitStatus == QProcess::NormalExit
           && mProcessError == QProcess::UnknownError;
}
开发者ID:pangpangpang3,项目名称:GammaRay,代码行数:42,代码来源:processinjector.cpp

示例9: compositorEnv

QProcessEnvironment CompositorLauncher::compositorEnv() const
{
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

    // Standard environment
//    env.insert(QStringLiteral("QT_QPA_PLATFORMTHEME"), QStringLiteral("Material"));
//    env.insert(QStringLiteral("QT_QUICK_CONTROLS_STYLE"), QStringLiteral("Material"));
//    env.insert(QStringLiteral("XCURSOR_THEME"), QStringLiteral("Adwaita"));
//    env.insert(QStringLiteral("XCURSOR_SIZE"), QStringLiteral("16"));
    env.insert(QStringLiteral("QSG_RENDER_LOOP"), QStringLiteral("windows"));

    // Specific environment
    switch (m_mode) {
    case EglFSMode:
        // General purpose distributions do not have the proper eglfs
        // integration and may want to build it out of tree, let them
        // specify a QPA plugin with an environment variable
        if (qEnvironmentVariableIsSet("U2T_QPA_PLATFORM"))
            env.insert(QStringLiteral("QT_QPA_PLATFORM"), qgetenv("U2T_QPA_PLATFORM"));
        else
            // FIXME this should not be eglfs and shold be xcb unless wayland
            env.insert(QStringLiteral("QT_QPA_PLATFORM"), QStringLiteral("eglfs"));

        switch (m_hardware) {
        case BroadcomHardware:
            env.insert(QStringLiteral("QT_QPA_EGLFS_INTEGRATION"), QStringLiteral("eglfs_brcm"));
            break;
        default:
            env.insert(QStringLiteral("QT_QPA_EGLFS_INTEGRATION"), QStringLiteral("eglfs_kms"));
            env.insert(QStringLiteral("QT_QPA_EGLFS_KMS_CONFIG"),
                       QStandardPaths::locate(QStandardPaths::GenericDataLocation,
                                              QStringLiteral("u2t-shell/eglfs/eglfs_kms.json")));
            break;
        }

        if (m_hasLibInputPlugin)
            env.insert(QStringLiteral("QT_QPA_EGLFS_DISABLE_INPUT"), QStringLiteral("1"));
        break;
    case X11Mode:
        env.insert(QStringLiteral("QT_XCB_GL_INTEGRATION"), QStringLiteral("xcb_egl"));
        break;
    default:
        break;
    }

    return env;
}
开发者ID:JosephMillsAtWork,项目名称:u2t,代码行数:47,代码来源:compositorlauncher.cpp

示例10: replaceWindowsEnvironmentVariables

QString QInstaller::replaceWindowsEnvironmentVariables(const QString &str)
{
    const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString res;
    int pos = 0;
    while (true) {
        int pos1 = str.indexOf(QLatin1Char( '%'), pos);
        if (pos1 == -1)
            break;
        int pos2 = str.indexOf(QLatin1Char( '%'), pos1 + 1);
        if (pos2 == -1)
            break;
        res += str.mid(pos, pos1 - pos);
        QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
        res += env.value(name);
        pos = pos2 + 1;
    }
    res += str.mid(pos);
    return res;
}
开发者ID:qtproject,项目名称:installer-framework,代码行数:20,代码来源:utils.cpp

示例11: vcsCommandString

bool MercurialClient::synchronousPull(const QString &workingDir, const QString &srcLocation, const QStringList &extraOptions)
{
    QStringList args;
    args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
    // Disable UNIX terminals to suppress SSH prompting
    const unsigned flags =
            VcsCommand::SshPasswordPrompt
            | VcsCommand::ShowStdOut
            | VcsCommand::ShowSuccessMessage;

    // cause mercurial doesn`t understand LANG
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
    const SynchronousProcessResponse resp = VcsBasePlugin::runVcs(
                workingDir, vcsBinary(), args, vcsTimeoutS(), flags, nullptr, env);
    const bool ok = resp.result == SynchronousProcessResponse::Finished;

    parsePullOutput(resp.stdOut().trimmed());
    return ok;
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:20,代码来源:mercurialclient.cpp

示例12: doInternetPingTest

/*
 * Pings google site, to make sure internet is OK
 */
bool UnixCommand::doInternetPingTest()
{
  QProcess ping;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  ping.setProcessEnvironment(env);

  if (UnixCommand::getLinuxDistro() == ectn_MOOOSLINUX)
    ping.start("torsocks ping -c 1 -W 3 www.google.com");
  else
    ping.start("ping -c 1 -W 3 www.google.com");

  ping.waitForFinished();

  int res = ping.exitCode();
  ping.close();

  return (res == 0);
}
开发者ID:ColinDuquesnoy,项目名称:octopi,代码行数:23,代码来源:unixcommand.cpp

示例13: QProcessEnvironmenttoScriptValue

// TODO: remove as much of this file as possible, as most of it isn't necessary
QScriptValue QProcessEnvironmenttoScriptValue(QScriptEngine *engine, const QProcessEnvironment &item)
{
  QScriptValue result = engine->newObject();
  QStringList env = item.toStringList();
  for (int i = 0; i < env.size(); i++)
  {
    QStringList line = env[i].split("=");
    result.setProperty(line[0], line[1]);
  }
  return result;
}
开发者ID:ChristopherCotnoir,项目名称:qt-client,代码行数:12,代码来源:qprocessenvironmentproto.cpp

示例14: run

void GoplayBrowser::run()
{
    m_editor->saveAs(m_playFile);
    if (!m_editFile.isEmpty()) {
        m_editor->saveAs(m_editFile);
    }
    QProcessEnvironment env = LiteApi::getCurrentEnvironment(m_liteApp);
    QString go = FileUtil::lookPath("go",env,false);
    QStringList args;
    args << "run";
    args << "goplay.go";
    if (m_process->isRuning()) {
        m_process->kill();
    }
    m_output->clear();
    m_output->appendTag(QString("Run start ...\n\n"));
    m_process->setEnvironment(env.toStringList());

    m_process->start(go,args);
}
开发者ID:bezigon,项目名称:liteide,代码行数:20,代码来源:goplaybrowser.cpp

示例15: QProcess

void TgtProcessIntf::tgtMakeConnection()
{
    std::shared_ptr<const TgtConnectionConfig> connectionConfig = std::dynamic_pointer_cast<const TgtConnectionConfig>(
        _connectionConfig);
    _proc = new QProcess(this);
    connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
    connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
    connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processDone(int,QProcess::ExitStatus)));
    _proc->setWorkingDirectory(connectionConfig->_workingDir.c_str());
    QStringList args(connectionConfig->_args.c_str());

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TERM", "xterm");
    env.insert("COLORTERM", "gnome-terminal");
    _proc->setProcessEnvironment(env);

    _proc->start(connectionConfig->_program.c_str(), args);
    _processWriterThread = TgtThread::create(boost::protect(std::bind(&TgtProcessIntf::writerThread, this)));
}
开发者ID:cdesjardins,项目名称:ComBomb,代码行数:20,代码来源:TgtProcessConnection.cpp


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