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


C++ QTextStream::flush方法代码示例

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


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

示例1: messageHandler

void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg)
{
    QMutexLocker locker(&m_mutex);

    QString out = QDateTime::currentDateTime().time().toString("hh:mm:ss:zzz") + " ";
    switch (type) {
    case QtDebugMsg:
        out.append("Debug: " + msg);
        cout << out.toStdString() << endl;
        break;
    case QtWarningMsg:
        out.append("Warning: " + msg);
        cerr << out.toStdString() << endl;
        break;
    case QtCriticalMsg:
        out.append("Critical: " + msg);
        cerr << out.toStdString() << endl;
        break;
    case QtFatalMsg:
        cerr << "Fatal: " << msg.toStdString() << endl;
        cerr.flush();

        m_logStream << "Fatal: " << msg << endl;
        m_logStream.flush();

        QApplication::exit(LightpackApplication::QFatalMessageHandler_ErrorCode);
    }

    m_logStream << out << endl;
    m_logStream.flush();
    cerr.flush();
    cout.flush();
}
开发者ID:luckygerbils,项目名称:Lightpack,代码行数:33,代码来源:main.cpp

示例2: menu_Parametr

/**
Редактировать атрибуты шрифта.
*/
void font::menu_Parametr ( void )
{
	int rez  = 0;
	int above = 0;
	int below = 0;
	int modes = 0;

	QString  attribute;

	do
	{
		print();
//  edit_menu::s_menu_font_parametr->run();
//  rez = edit_menu::s_menu_font_parametr->get_run_rez();

		switch ( rez )
		{

			case 0: //Above
				std_out << "Above (n>=1) <" << get_above () << "> =";
				std_out.flush();
				std_in >> above ;
				set_above ( above );
				break;

			case 1: //Below
				std_out << "Below (n>=1) <" << get_below() << "> =";
				std_out.flush();
				std_in >> below;
				set_below ( below );
				break;

			case 2: //Modes
				std_out << "Modes (0|2) <" << get_modes() << "> =";
				std_out.flush();
				std_in >> modes;
				set_modes ( modes );
				break;

			case 3: //Attribute
				std_out << "Attribute <" << get_attribute() << "> =";
				std_out.flush();
				attribute = std_in.readLine();
//    std_in >> attribute;
				set_attribute ( attribute );
				break;

			case 4: //Exit
				break;

			default:
				rez = 4;
				break;
		}
	}

	while ( rez >= 0 && rez < 4 );
}
开发者ID:mnasoft,项目名称:AutoShape,代码行数:61,代码来源:font.cpp

示例3: print

    void print(const std::string & log)
    {
        QMutexLocker locker(&_lock);

        assert(_file);
        for (int i = 0; i < _beginsCount; ++i) {
            _stream->operator <<("    ");
        }
        QString str( log.c_str() );
        for (int i = 0; i < str.size(); ++i) {
            _stream->operator <<( str.at(i).toAscii() );
            if ( (i % 80 == 0) && (i != 0) ) { // format to 80 columns
                /*Find closest word end and insert a new line*/
                ++i;
                while ( i < str.size() && str.at(i) != QChar(' ') ) {
                    _stream->operator <<( str.at(i).toAscii() );
                    ++i;
                }
                _stream->operator <<('\n');
                for (int i = 0; i < _beginsCount; ++i) {
                    _stream->operator <<("    ");
                }
            }
        }
        _stream->operator <<( log.c_str() );
        _stream->operator <<('\n');
        _stream->flush();
    }
开发者ID:ChristianHeckl,项目名称:Natron,代码行数:28,代码来源:Log.cpp

示例4: writeCsv

void Ledger::writeCsv(QTextStream &stream)
{
    int i, j;
    QString field;
    for( i=0; i<rowCount(); i++ ){
        if( i==rowCount()-1 && isEmptyRow(i) )
            break;
        for( j=0; j<NCOL; j++ ){
            if( !item(i,j) || item(i,j)->data(Qt::EditRole).isNull() )
                field = "";
            else if( j==COL_DATE )
                field = item(i,j)->data(Qt::EditRole).toDate().toString(Qt::ISODate);
            else if( j==COL_PRICE )
                field.setNum(item(i,j)->data(Qt::EditRole).toDouble(),'f',2);
            else{
                field = item(i,j)->data(Qt::EditRole).toString();
                if( field.contains( QRegularExpression("[\",\n]") ) ){
                    field.replace("\"", "\"\"");
                    field.prepend(QChar('\"'));
                    field.append(QChar('\"'));
                }
            }
            stream << field;
            if(j==NCOL-1) stream << '\n';
            else stream << ',';
        }
    }
    stream.flush();
    undoStack->setClean();
}
开发者ID:cfbao,项目名称:Accounting,代码行数:30,代码来源:ledger.cpp

示例5: saveCall

void MinimalHistoryEditor::saveCall(QTextStream& stream, const Call* call)
{
   const QString direction = (call->direction()==Call::Direction::INCOMING)?
      Call::HistoryStateName::INCOMING : Call::HistoryStateName::OUTGOING;

   const Account* a = call->account();
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::CALLID          ).arg(call->historyId()                     );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::TIMESTAMP_START ).arg(call->startTimeStamp()         );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::TIMESTAMP_STOP  ).arg(call->stopTimeStamp()          );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::ACCOUNT_ID      ).arg(a?QString(a->id()):""          );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::DISPLAY_NAME    ).arg(call->peerName()               );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::PEER_NUMBER     ).arg(call->peerContactMethod()->uri() );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::DIRECTION       ).arg(direction                      );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::MISSED          ).arg(call->isMissed()               );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::RECORDING_PATH  ).arg(call->recordingPath()          );
   stream << QString("%1=%2\n").arg(Call::HistoryMapFields::CONTACT_USED    ).arg(false                          );//TODO
   if (call->peerContactMethod()->contact()) {
      stream << QString("%1=%2\n").arg(Call::HistoryMapFields::CONTACT_UID  ).arg(
         QString(call->peerContactMethod()->contact()->uid())
      );
   }
   if (call->certificate())
      stream << QString("%1=%2\n").arg(Call::HistoryMapFields::CERT_PATH).arg(call->certificate()->path().path());
   stream << "\n";
   stream.flush();
}
开发者ID:Elv13,项目名称:sflphone-kde,代码行数:26,代码来源:minimalhistorybackend.cpp

示例6: generateDcfSubSections

void generateDcfSubSections( QString indent, QTextStream& out, const DcfSection& sect )
{
    QList<DcfSection>::const_iterator ss = sect.subsections.constBegin();
    while ( ss != sect.subsections.constEnd() ) {
	out << indent << "<section ref=\"" << HtmlGenerator::cleanRef(HtmlGenerator::protect((*ss).ref))
            << "\" title=\"" << HtmlGenerator::protect((*ss).title) << "\"";
	if ((*ss).keywords.isEmpty() && (*ss).subsections.isEmpty()) {
	    out << "/>\n";
	} else {
	    out << ">\n";
	    QString indentIndent = indent + "    ";
	    QList<QPair<QString, QString> >::const_iterator k = (*ss).keywords.constBegin();
	    while ( k != (*ss).keywords.constEnd() ) {
		out << indentIndent << "<keyword ref=\"" << HtmlGenerator::cleanRef((*k).second) << "\">"
                    << HtmlGenerator::protect((*k).first) << "</keyword>\n";
		++k;
	    }

            generateDcfSubSections( indentIndent, out, *ss );
	    out << indent << "</section>\n";
	}
	++ss;
    }
    out.flush();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:25,代码来源:dcfsection.cpp

示例7: myMessageOutput

void myMessageOutput(QtMsgType type, const char *msg)
{
     //in this function, you can write the message to any stream!
    stream << QString(msg);
    stream << QString("\n");
    stream.flush();
}
开发者ID:xxmicloxx,项目名称:GSPlayerQT,代码行数:7,代码来源:main.cpp

示例8: LINE_END

void ImageHistogram<T>::toAscii( QTextStream& out ) const {
    const QString LINE_END( "\n");
    QString centerStr( "#Bin Center(");
    casa::Unit unit = ImageHistogram::m_image->units();
    QString unitStr( unit.getName().c_str());
    centerStr.append( unitStr + ")");
    out << centerStr << "Count";
    out << LINE_END;
    out.flush();
    int count = m_xValues.size();
    for ( int i = 0; i < count; i++ ) {
        out << QString::number(m_xValues[i]) << QString::number( m_yValues[i]);
        out << LINE_END;
        out.flush();
    }
}
开发者ID:astrilet,项目名称:CARTAvis,代码行数:16,代码来源:ImageHistogram.cpp

示例9: xsltFileName

void Docbook2XhtmlGeneratorJob::run()
{
  UMLDoc* umlDoc = UMLApp::app()->document();
  xsltStylesheetPtr cur = NULL;
  xmlDocPtr doc, res;

  const char *params[16 + 1];
  int nbparams = 0;
  params[nbparams] = NULL;

  umlDoc->writeToStatusBar(i18n("Exporting to XHTML..."));

  QString xsltFileName(KGlobal::dirs()->findResource("appdata", QLatin1String("docbook2xhtml.xsl")));
  uDebug() << "XSLT file is'" << xsltFileName << "'";
  QFile xsltFile(xsltFileName);
  xsltFile.open(QIODevice::ReadOnly);
  QString xslt = QString::fromLatin1(xsltFile.readAll());
  uDebug() << "XSLT is'" << xslt << "'";
  xsltFile.close();

  QString localXsl = KGlobal::dirs()->findResource("data", QLatin1String("ksgmltools2/docbook/xsl/html/docbook.xsl"));
  uDebug() << "Local xsl is'" << localXsl << "'";
  if (!localXsl.isEmpty())
  {
    localXsl = QLatin1String("href=\"file://") + localXsl + QLatin1String("\"");
    xslt.replace(QRegExp(QLatin1String("href=\"http://[^\"]*\"")), localXsl);
  }
  KTemporaryFile tmpXsl;
  tmpXsl.setAutoRemove(false);
  tmpXsl.open();
  QTextStream str (&tmpXsl);
  str << xslt;
  str.flush();

  xmlSubstituteEntitiesDefault(1);
  xmlLoadExtDtdDefaultValue = 1;
  uDebug() << "Parsing stylesheet " << tmpXsl.fileName();
  cur = xsltParseStylesheetFile((const xmlChar *)tmpXsl.fileName().toLatin1().constData());
  uDebug() << "Parsing file " << m_docbookUrl.path();
  doc = xmlParseFile((const char*)(m_docbookUrl.path().toUtf8()));
  uDebug() << "Applying stylesheet ";
  res = xsltApplyStylesheet(cur, doc, params);

  KTemporaryFile tmpXhtml;
  tmpXhtml.setAutoRemove(false);
  tmpXhtml.open();

  uDebug() << "Writing HTML result to temp file: " << tmpXhtml.fileName();
  xsltSaveResultToFd(tmpXhtml.handle(), res, cur);

  xsltFreeStylesheet(cur);
  xmlFreeDoc(res);
  xmlFreeDoc(doc);

  xsltCleanupGlobals();
  xmlCleanupParser();

  emit xhtmlGenerated(tmpXhtml.fileName());
}
开发者ID:behlingc,项目名称:umbrello-behlingc,代码行数:59,代码来源:docbook2xhtmlgeneratorjob.cpp

示例10: writeEOS

void ScriptHelper::writeEOS(QTextStream& script) {
	script
			<< endl
			<< "@@@"
			<< endl;

	// ensure everything is written to the stream
	script.flush();
}
开发者ID:BackupTheBerlios,项目名称:qtfin-svn,代码行数:9,代码来源:scripthelper.cpp

示例11: menu_Ascii

void font::menu_Ascii ( void )
{
	int rez  = 0;
	QString  str;
	ushort  rez_ushort;
	QString   fileName;

	do
	{
		switch ( rez )
		{

			case 1: //ASCII
				std_out << "ASCII:";
				std_out.flush();
				std_in >> str;

				if ( str.length() >=  1 )
				{
					rez_ushort = str[0].unicode () ;
//     number = rez_ushort;
				}

				break;

			case 2: //Attribute
				std_out << "Enter Attribute:";
				std_out.flush();
				std_in >> str;
				m_comment = str;
				break;

			case 3: //Restore
				m_comment = QString ( "Nothing" );
//    number = -1;
				break;

			default:
				break;
		}
	}

	while ( rez >= 0 );
}
开发者ID:mnasoft,项目名称:AutoShape,代码行数:44,代码来源:font.cpp

示例12: saveChanges

bool plotsDialog::saveChanges()
{
#ifdef Q_OS_WIN32
    QFile ofile(globalpara.caseName),file("plotTemp.xml");
#endif
#ifdef Q_OS_MAC
    QDir dir = qApp->applicationDirPath();
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    QString bundleDir(dir.absolutePath());
    QFile ofile(globalpara.caseName),file(bundleDir+"/plotTemp.xml");
#endif
    QDomDocument odoc,doc;
    QDomElement oroot;
    QTextStream stream;
    stream.setDevice(&ofile);
    if(!ofile.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        globalpara.reportError("Fail to open case file to update plot data.",this);
        return false;
    }
    else if(!odoc.setContent(&ofile))
    {
        globalpara.reportError("Fail to load xml document from case file to update plot data.",this);
        return false;
    }
    if(!file.open(QIODevice::ReadOnly|QIODevice::Text))
    {
        globalpara.reportError("Fail to open plot temp file to update plot data.",this);
        return false;
    }
    else if(!doc.setContent(&file))
    {
        globalpara.reportError("Fail to load xml document from plot temp file to update plot data..",this);
        return false;
    }
    else
    {
        QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement();
        QDomNode copiedPlot = plotData.cloneNode(true);
        oroot = odoc.elementsByTagName("root").at(0).toElement();
        oroot.replaceChild(copiedPlot,odoc.elementsByTagName("plotData").at(0));

        ofile.resize(0);
        odoc.save(stream,4);
        file.close();
        ofile.close();
        stream.flush();
        return true;
    }
}
开发者ID:oabdelaziz,项目名称:SorpSim,代码行数:52,代码来源:plotsdialog.cpp

示例13: Write

bool FormattedTouchstone::Write(FormattedNetworkData &network, QTextStream &FormattedTouchstone_out) {
    WriteComments(network, FormattedTouchstone_out);
    WriteOptions(network, FormattedTouchstone_out);
    if (network.numberOfPorts() != 2)
        WriteData(network, FormattedTouchstone_out);
    else {
        FormattedNetworkData copyNetwork = network;
        Flip2Ports(copyNetwork);
        WriteData(copyNetwork, FormattedTouchstone_out);
    }
    FormattedTouchstone_out.flush();
    return(true);
}
开发者ID:Terrabits,项目名称:RsaToolbox,代码行数:13,代码来源:FormattedTouchstone.cpp

示例14: on_copyButton_clicked

void plotsDialog::on_copyButton_clicked()
{
    QString pName = tabs->tabText(tabs->currentIndex());
    QString newName = pName+"Copy";
#ifdef Q_OS_WIN32
    QFile file("plotTemp.xml");
#endif
#ifdef Q_OS_MAC
    QDir dir = qApp->applicationDirPath();
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    QString bundleDir(dir.absolutePath());
    QFile file(bundleDir+"/plotTemp.xml");
#endif
    QTextStream stream;
    stream.setDevice(&file);
    if(!file.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        globalpara.reportError("Fail to open case file to copy plot.",this);
        return;
    }
    else
    {
        QDomDocument doc;
        if(!doc.setContent(&file))
        {
            globalpara.reportError("Fail to load xml document to copy plot.....",this);
            file.close();
            return;
        }
        else
        {
            QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement();
            if(!plotData.elementsByTagName(pName).isEmpty())
            {

                QDomNode newNode = plotData.elementsByTagName(pName).at(0).cloneNode(true);
                newNode.toElement().setTagName(newName);
                plotData.appendChild(newNode);

            }
        }
        file.resize(0);
        doc.save(stream,4);
        file.close();
        stream.flush();
    }

    setupPlots(false);
}
开发者ID:oabdelaziz,项目名称:SorpSim,代码行数:51,代码来源:plotsdialog.cpp

示例15: logMsg

inline void logMsg(const QString &msg) {
    static QFile logFile(LogFileName);
    static QTextStream qts;

    if (!logFile.isOpen()) {
        if (!logFile.open(QFile::WriteOnly | QIODevice::Append)) {
            throw std::runtime_error("Failed to open log file");
        }
        qts.setDevice(&logFile);
    }

    qts << msg << "\n";
    qts.flush();
}
开发者ID:Leonid-SPB,项目名称:QWorkBreak,代码行数:14,代码来源:Logger.hpp


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