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


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

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


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

示例1: readChannel

QProcess::ProcessChannel QProcessProto::readChannel() const
{
  QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
  if (item)
    return item->readChannel();
  return QProcess::ProcessChannel();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: readDataFromProcess

// Static utilities: Keep running as long as it gets data.
bool SynchronousProcess::readDataFromProcess(QProcess &p, int timeOutMS,
                                             QByteArray *stdOut, QByteArray *stdErr,
                                             bool showTimeOutMessageBox)
{
    if (syncDebug)
        qDebug() << ">readDataFromProcess" << timeOutMS;
    if (p.state() != QProcess::Running) {
        qWarning("readDataFromProcess: Process in non-running state passed in.");
        return false;
    }

    QTC_ASSERT(p.readChannel() == QProcess::StandardOutput, return false)

    // Keep the process running until it has no longer has data
    bool finished = false;
    bool hasData = false;
    do {
        finished = p.waitForFinished(timeOutMS);
        hasData = false;
        // First check 'stdout'
        if (p.bytesAvailable()) { // applies to readChannel() only
            hasData = true;
            const QByteArray newStdOut = p.readAllStandardOutput();
            if (stdOut)
                stdOut->append(newStdOut);
        }
        // Check 'stderr' separately. This is a special handling
        // for 'git pull' and the like which prints its progress on stderr.
        const QByteArray newStdErr = p.readAllStandardError();
        if (!newStdErr.isEmpty()) {
            hasData = true;
            if (stdErr)
                stdErr->append(newStdErr);
        }
        // Prompt user, pretend we have data if says 'No'.
        const bool hang = !hasData && !finished;
        if (hang && showTimeOutMessageBox) {
            if (!askToKill())
                hasData = true;
        }
    } while (hasData && !finished);
    if (syncDebug)
        qDebug() << "<readDataFromProcess" << finished;
    return finished;
}
开发者ID:yinyunqiao,项目名称:qtcreator,代码行数:46,代码来源:synchronousprocess.cpp

示例3: saveEdit

void Area::saveEdit(int del){

    //temporary file for the text edition

    QFile newph("temp.ph");

    newph.open(QIODevice::WriteOnly | QIODevice::Truncate);
    QTextStream flux(&newph);
    flux.setCodec("UTF-8");    

    QString *file = new QString("temp.ph");
    QString fileXML("tempXML.xml");
    std::string phFile = file->toStdString();

    try{

        //Save new text into new file
        if(this->textArea->toPlainText().isEmpty()){

            throw textAreaEmpty_exception();
        }

        flux << this->textArea->toPlainText() << endl;

        newph.close();        

        if(del == 0){

            emit makeTempXML();
        }

        // render graph
        PHPtr myPHPtr = PHIO::parseFile(phFile);
        this->myArea->setPHPtr(myPHPtr);
        myPHPtr->render();
        PHScenePtr scene = myPHPtr->getGraphicsScene();
        this->myArea->setScene(&*scene);

        // delete the current sortsTree and groupsTree
        this->treeArea->sortsTree->clear();
        //this->treeArea->groupsTree->clear();
        // set the pointer of the treeArea
        this->treeArea->myPHPtr = myPHPtr;
        //set the pointer of the treeArea
        this->treeArea->myArea = this->myArea;
        // build the tree in the treeArea
        this->treeArea->build();

        this->indicatorEdit->setVisible(false);       
        this->saveTextEdit->setDefault(false);
        this->textArea->incrementeNberTextChange();        
        this->typeOfCancel = 0;
        this->saveTextEdit->setEnabled(false);        
        this->textArea->setNberEdit(0);
        this->cancelTextEdit->setShortcut(QKeySequence());

        this->setOldText();

        newph.remove();

        this->mainWindow->importXMLMetadata(fileXML);
    }
    catch(textAreaEmpty_exception & e){

        QMessageBox::critical(this, "Error !", "You cannot update from an empty text area !");
    }
    catch(ph_parse_error & argh){

        //Catch a parsing error !
        //Put the exception into a QMessageBox critical

        QString phc = "phc";
        QStringList args;
        args << "-l" << "dump" << "-i" << QString::fromUtf8(phFile.c_str()) << "--no-debug";
        QProcess *phcProcess = new QProcess();
        phcProcess->start(phc, args);
        if (!phcProcess->waitForStarted())
            throw pint_program_not_found() << file_info("phc");

        phcProcess->readChannel();

        // read result
        QByteArray stderr;
        QByteArray stdout;
        while (!phcProcess->waitForFinished()) {
            stderr += phcProcess->readAllStandardError();
            stdout += phcProcess->readAllStandardOutput();
        }
        stderr += phcProcess->readAllStandardError();
        stdout += phcProcess->readAllStandardOutput();
        delete phcProcess;

        //Use split function to only keep the line number

        QStringList list = QString(stderr).split('"');
        QStringList list2 = list[1].split(":");
        QStringList list3 = list2[0].split(" ");

        //One or more of your expressions are wrong !
        newph.remove();
//.........这里部分代码省略.........
开发者ID:GrasJulien,项目名称:appli,代码行数:101,代码来源:Area.cpp


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