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


C++ QXmlStreamWriter::hasError方法代码示例

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


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

示例1: return

// Write the current Ranges portion of controls to an XML stream
bool US_RunProtocol::RunProtoRanges::toXml( QXmlStreamWriter& xmlo )
{
   nranges              = chrngs.count();
   xmlo.writeStartElement( "ranges" );
   for ( int ii = 0; ii < nranges; ii++ )
   {
      xmlo.writeStartElement( "range" );
      xmlo.writeAttribute   ( "channel",      chrngs[ ii ].channel );
      xmlo.writeAttribute   ( "start_radius",
                              QString::number( chrngs[ ii ].lo_rad ) );
      xmlo.writeAttribute   ( "end_radius",
                              QString::number( chrngs[ ii ].hi_rad ) );
      for ( int jj = 0; jj < chrngs[ ii ].wvlens.count(); jj++ )
      {
         xmlo.writeStartElement( "wavelength" );
         xmlo.writeAttribute   ( "lambda",
                                 QString::number( chrngs[ ii ].wvlens[ jj ] ) );
         xmlo.writeEndElement(); // wavelength
      }
      xmlo.writeEndElement(); // range
   }
   xmlo.writeEndElement(); // ranges

   return ( ! xmlo.hasError() );
}
开发者ID:svn2github,项目名称:UltraScan3,代码行数:26,代码来源:us_run_protocol.cpp

示例2: toXml

// Write all current controls to an XML stream
bool US_RunProtocol::toXml( QXmlStreamWriter& xmlo )
{
   xmlo.writeStartDocument();
   xmlo.writeDTD          ( "<!DOCTYPE US_RunProtocol>" );
   xmlo.writeStartElement ( "ProtocolData" );
   xmlo.writeAttribute    ( "version", "1.0" );

   xmlo.writeStartElement ( "protocol" );
   xmlo.writeAttribute    ( "description",  protname );
   xmlo.writeAttribute    ( "guid",         pGUID );
   xmlo.writeAttribute    ( "optima_host",  optimahost );
   xmlo.writeAttribute    ( "investigator", investigator );
   xmlo.writeAttribute    ( "temperature",  QString::number( temperature ) );
   xmlo.writeAttribute    ( "temeq_delay",  QString::number( temeq_delay ) );

   rpRotor.toXml( xmlo );
   rpSpeed.toXml( xmlo );
   rpCells.toXml( xmlo );
   rpSolut.toXml( xmlo );
   rpOptic.toXml( xmlo );
   rpRange.toXml( xmlo );

   xmlo.writeEndElement();    // protocol

   xmlo.writeEndElement();    // ProtocolData
   xmlo.writeEndDocument();

   return ( ! xmlo.hasError() );
}
开发者ID:svn2github,项目名称:UltraScan3,代码行数:30,代码来源:us_run_protocol.cpp

示例3: setXML

void Table::setXML(QXmlStreamWriter& w) const{
    int s=datalist.size();
    for(int i=0;i<s && !w.hasError();i++)
    {
        QString xname=datalist[i]->getName()->text();
        QString xtype=datalist[i]->getType()->text();
        QString xlv=datalist[i]->getLV()->text();
        QString xstrength=datalist[i]->getStrength()->text();
        QString xconstitution=datalist[i]->getConstitution()->text();
        w.writeStartElement(xtype);
        w.writeTextElement("Name",xname);
        w.writeTextElement("LV",xlv);
        w.writeTextElement("Strength",xstrength);
        w.writeTextElement("Constitution",xconstitution);
        if(xtype!="Golem")
        {
            QString xmp=datalist[i]->getMP()->text();
            QString xwisdom=datalist[i]->getWisdom()->text();
            w.writeTextElement("MP",xmp);
            w.writeTextElement("Wisdom",xwisdom);
        }
        w.writeEndElement();
    }
}
开发者ID:StefanoMunari,项目名称:qDB,代码行数:24,代码来源:table.cpp

示例4: saveMOJ

bool Document::saveMOJ(QString fileName)
{
  QFile file(fileName);
  if (!file.open(QIODevice::WriteOnly))
  {
    return false;
  }

  QXmlStreamWriter writer;

  writer.setAutoFormatting(true);

  writer.setDevice(&file);

  writer.writeStartDocument("1.0", false);
  writer.writeStartElement("MrWriter");
  QString version;
  version.append(QString::number(MAJOR_VERSION)).append(".").append(QString::number(MINOR_VERSION)).append(QString::number(PATCH_VERSION));
  writer.writeAttribute(QXmlStreamAttribute("version", version));
  QString docVersion = QString::number(DOC_VERSION);
  writer.writeAttribute(QXmlStreamAttribute("docversion", docVersion));

  writer.writeStartElement("title");
  writer.writeCharacters("MrWriter document - see http://unruhschuh.com/mrwriter/");
  writer.writeEndElement();

  for (int i = 0; i < pages.size(); ++i)
  {
    writer.writeStartElement("page");
    writer.writeAttribute(QXmlStreamAttribute("width", QString::number(pages[i].width())));
    writer.writeAttribute(QXmlStreamAttribute("height", QString::number(pages[i].height())));
    writer.writeEmptyElement("background");
    writer.writeAttribute(QXmlStreamAttribute("type", "solid"));
    writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(pages[i].backgroundColor().name(QColor::HexArgb))));
    writer.writeAttribute(QXmlStreamAttribute("style", "plain"));
    writer.writeStartElement("layer");

    //    for (int j = 0; j < pages[i].m_strokes.size(); ++j)
    for (auto strokes : pages[i].strokes())
    {
      writer.writeStartElement("stroke");
      writer.writeAttribute(QXmlStreamAttribute("tool", "pen"));
      writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(strokes.color.name(QColor::HexArgb))));
      QString patternString;
      if (strokes.pattern == MrDoc::solidLinePattern)
      {
        patternString = "solid";
      }
      else if (strokes.pattern == MrDoc::dashLinePattern)
      {
        patternString = "dash";
      }
      else if (strokes.pattern == MrDoc::dashDotLinePattern)
      {
        patternString = "dashdot";
      }
      else if (strokes.pattern == MrDoc::dotLinePattern)
      {
        patternString = "dot";
      }
      else
      {
        patternString = "solid";
      }
      writer.writeAttribute(QXmlStreamAttribute("style", patternString));
      qreal width = strokes.penWidth;
      writer.writeAttribute(QXmlStreamAttribute("width", QString::number(width)));
      QString pressures;
      for (int k = 0; k < strokes.pressures.length(); ++k)
      {
        pressures.append(QString::number(strokes.pressures[k])).append(" ");
      }
      writer.writeAttribute((QXmlStreamAttribute("pressures", pressures.trimmed())));
      QString points;
      for (int k = 0; k < strokes.points.size(); ++k)
      {
        points.append(QString::number(strokes.points[k].x()));
        points.append(" ");
        points.append(QString::number(strokes.points[k].y()));
        points.append(" ");
      }
      writer.writeCharacters(points.trimmed());
      writer.writeEndElement(); // closing "stroke"
    }

    writer.writeEndElement(); // closing "layer"
    writer.writeEndElement(); // closing "page"
  }

  writer.writeEndDocument();

  QFileInfo fileInfo(file);

  file.close();

  if (writer.hasError())
  {
    return false;
  }
  else
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:MrWriter,代码行数:101,代码来源:document.cpp

示例5: saveXOJ

bool Document::saveXOJ(QString fileName)
{
  QFile file(fileName);
  if (!file.open(QIODevice::WriteOnly))
  {
    return false;
  }

  QXmlStreamWriter writer;

  writer.setAutoFormatting(true);

  writer.setDevice(&file);

  writer.writeStartDocument("1.0", false);
  writer.writeStartElement("xournal");
  writer.writeAttribute(QXmlStreamAttribute("version", "0.4.8"));

  writer.writeStartElement("title");
  writer.writeCharacters("Xournal document - see http://math.mit.edu/~auroux/software/xournal/");
  writer.writeEndElement();

  for (int i = 0; i < pages.size(); ++i)
  {
    writer.writeStartElement("page");
    writer.writeAttribute(QXmlStreamAttribute("width", QString::number(pages[i].width())));
    writer.writeAttribute(QXmlStreamAttribute("height", QString::number(pages[i].height())));
    writer.writeEmptyElement("background");
    writer.writeAttribute(QXmlStreamAttribute("type", "solid"));
    writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(pages[i].backgroundColor().name(QColor::HexArgb))));
    writer.writeAttribute(QXmlStreamAttribute("style", "plain"));
    writer.writeStartElement("layer");

    //    for (int j = 0; j < pages[i].m_strokes.size(); ++j)
    for (auto strokes : pages[i].strokes())
    {
      writer.writeStartElement("stroke");
      writer.writeAttribute(QXmlStreamAttribute("tool", "pen"));
      writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(strokes.color.name(QColor::HexArgb))));
      qreal width = strokes.penWidth;
      QString widthString;
      widthString.append(QString::number(width));
      for (int k = 0; k < strokes.pressures.size() - 1; ++k)
      {
        qreal p0 = strokes.pressures[k];
        qreal p1 = strokes.pressures[k + 1];
        widthString.append(' ');
        widthString.append(QString::number(0.5 * (p0 + p1) * width));
      }
      writer.writeAttribute(QXmlStreamAttribute("width", widthString));
      for (int k = 0; k < strokes.points.size(); ++k)
      {
        writer.writeCharacters(QString::number(strokes.points[k].x()));
        writer.writeCharacters(" ");
        writer.writeCharacters(QString::number(strokes.points[k].y()));
        writer.writeCharacters(" ");
      }
      writer.writeEndElement(); // closing "stroke"
    }

    writer.writeEndElement(); // closing "layer"
    writer.writeEndElement(); // closing "page"
  }

  writer.writeEndDocument();

  QFileInfo fileInfo(file);

  file.close();

  if (writer.hasError())
  {
    return false;
  }
  else
  {
    return true;
  }
}
开发者ID:gitter-badger,项目名称:MrWriter,代码行数:79,代码来源:document.cpp


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