本文整理汇总了C++中QXmlStreamWriter::writeAttributes方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlStreamWriter::writeAttributes方法的具体用法?C++ QXmlStreamWriter::writeAttributes怎么用?C++ QXmlStreamWriter::writeAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlStreamWriter
的用法示例。
在下文中一共展示了QXmlStreamWriter::writeAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void CameraManager::save(QXmlStreamWriter& writer) {
writer.writeStartElement("Camera"); // root element start
writer.writeStartElement("input size"); // element1 start
QXmlStreamAttributes inputSizes;
inputSizes.append("width", QtUtil::toQString(_size.width));
inputSizes.append("height", QtUtil::toQString(_size.width));
writer.writeAttributes(inputSizes);
writer.writeEndElement(); // element1 end
writer.writeEndElement(); // root end
}
示例2: addTabData
void SessionWriter::addTabData(const TabData& td){
m_writer.writeStartElement("Tab");
QXmlStreamAttributes attrs;
attrs.push_back(QXmlStreamAttribute("filePath", td.filePath));
attrs.push_back(QXmlStreamAttribute("cacheFilePath", td.cacheFilePath));
attrs.push_back(QXmlStreamAttribute("scrollX", QString::number(td.scrollX)));
attrs.push_back(QXmlStreamAttribute("scrollY", QString::number(td.scrollY)));
// A few attributes aren't often used, so we'll only write them into the file if they're
// set to a non-default value as to not clutter up the xml file.
if (!td.language.isEmpty())
attrs.push_back(QXmlStreamAttribute("language", td.language));
if (td.lastModified != 0)
attrs.push_back(QXmlStreamAttribute("lastModified", QString::number(td.lastModified)));
if (td.active)
attrs.push_back(QXmlStreamAttribute("active", "1"));
m_writer.writeAttributes(attrs);
m_writer.writeEndElement();
}
示例3: writeXml
void LapTimerThread::writeXml()
{
QXmlStreamReader xmlReader;
coordTmpFile.open(QIODevice::ReadOnly | QIODevice::Text);
xmlReader.setDevice(&coordTmpFile);
xmlReader.readNext();
int lapNum=0;
//Reading from the file
xmlReader.readNext();
while (!xmlReader.isEndDocument())
{
if (xmlReader.isStartElement())
{
QString name = xmlReader.name().toString();
if (name == "lap")
{
lapNum++;
}
}
else if (xmlReader.isEndElement())
{
}
xmlReader.readNext();
}
coordTmpFile.close();
for (int i=0;i<lapNum-1;i++)// loop to generate kml file for each lap
{
QFile xmlKmlFile;
QXmlStreamWriter bufferKml;
xmlKmlFile.setFileName("data/"+dirName+"/"+dirName+"-"+QString::number(i+1)+".kml");
xmlKmlFile.open(QIODevice::WriteOnly | QIODevice::Text);
bufferKml.setDevice(&xmlKmlFile);
bufferKml.setAutoFormatting(true);
bufferKml.writeStartDocument();
bufferKml.writeStartElement("kml");
QXmlStreamAttributes atrr;
atrr.append("xmlns","http://www.opengis.net/kml/2.2");
atrr.append("xmlns:gx","http://www.google.com/kml/ext/2.2");
atrr.append("xmlns:atom","http://www.w3.org/2005/Atom");
bufferKml.writeAttributes(atrr);
bufferKml.writeStartElement("Document");
bufferKml.writeTextElement("open","1");
bufferKml.writeTextElement("visibility","1");
bufferKml.writeStartElement("name");
bufferKml.writeCDATA("GPS Lap Timer - KML Log - "+QDate::currentDate().toString("yyyyMMdd")+QTime::currentTime().toString("hhmmss"));
bufferKml.writeEndElement();
//style - track
bufferKml.writeStartElement("Style");
bufferKml.writeAttribute(QXmlStreamAttribute("id","track"));
bufferKml.writeStartElement("LineStyle");
bufferKml.writeTextElement("color","7f0000ff");
bufferKml.writeTextElement("width","4");
bufferKml.writeEndElement();
bufferKml.writeStartElement("IconStyle");
bufferKml.writeTextElement("scale","1.3");
bufferKml.writeStartElement("Icon");
bufferKml.writeTextElement("href","http://earth.google.com/images/kml-icons/track-directional/track-0.png");
bufferKml.writeEndElement();
bufferKml.writeEndElement();
bufferKml.writeEndElement();
//style - start
bufferKml.writeStartElement("Style");
bufferKml.writeAttribute(QXmlStreamAttribute("id","start"));
bufferKml.writeStartElement("IconStyle");
bufferKml.writeTextElement("scale","1.3");
bufferKml.writeStartElement("Icon");
bufferKml.writeTextElement("href","http://maps.google.com/mapfiles/kml/paddle/grn-circle.png");
bufferKml.writeEndElement();
bufferKml.writeEmptyElement("hotSpot");
atrr.clear();
atrr.append("x","32");
atrr.append("y","1");
atrr.append("xunits","pixels");
atrr.append("yunits","pixels");
bufferKml.writeAttributes(atrr);
bufferKml.writeEndElement();
bufferKml.writeEndElement();
// style - end
bufferKml.writeStartElement("Style");
bufferKml.writeAttribute(QXmlStreamAttribute("id","end"));
bufferKml.writeStartElement("IconStyle");
bufferKml.writeTextElement("scale","1.3");
bufferKml.writeStartElement("Icon");
bufferKml.writeTextElement("href","http://maps.google.com/mapfiles/kml/paddle/red-circle.png");
bufferKml.writeEndElement();
bufferKml.writeEmptyElement("hotSpot");
bufferKml.writeAttributes(atrr);
bufferKml.writeEndElement();
bufferKml.writeEndElement();
// style - statistics
bufferKml.writeStartElement("Style");
bufferKml.writeAttribute(QXmlStreamAttribute("id","statistics"));
bufferKml.writeStartElement("IconStyle");
bufferKml.writeTextElement("scale","1.3");
bufferKml.writeStartElement("Icon");
//.........这里部分代码省略.........
示例4: GetImportOpmlFile
QString FirefoxProfileSelectPage::GetImportOpmlFile ()
{
QString rssSql ("SELECT ann.id, ann.item_id, ann.anno_attribute_id, ann.content,"
"bm.title FROM moz_items_annos ann,moz_bookmarks bm WHERE ann.item_id"
" IN (SELECT item_id FROM moz_items_annos WHERE anno_attribute_id = (SELECT"
" id FROM moz_anno_attributes WHERE name = 'livemark/feedURI')) AND ("
"ann.anno_attribute_id = 4 OR ann.anno_attribute_id = 5) AND "
"bm.id = ann.item_id");
QSqlQuery rssQuery = GetQuery (rssSql);
if (rssQuery.isValid ())
{
QSqlQuery query (*DB_);
query.exec ("SELECT id FROM moz_anno_attributes WHERE name='livemark/siteURI'");
query.next ();
int site = query.value (0).toInt ();
query.exec ("SELECT id FROM moz_anno_attributes WHERE name='livemark/feedURI'");
query.next ();
int feed = query.value (0).toInt ();
QList<QVariant> opmlData;
int prevItemId = -1;
QMap<QString, QVariant> omplLine;
do
{
if (rssQuery.value (2).toInt () == site)
omplLine ["SiteUrl"] = rssQuery.value (3).toString ();
if (rssQuery.value (2).toInt () == feed)
omplLine ["FeedUrl"] = rssQuery.value (3).toString ();
if (prevItemId == rssQuery.value (1).toInt ())
opmlData.push_back (omplLine);
else
{
prevItemId = rssQuery.value (1).toInt ();
omplLine ["Title"] = rssQuery.value (4).toString ();
}
}
while (rssQuery.next ());
QFile file ("firefox.opml");
if (file.open (QIODevice::WriteOnly))
{
QXmlStreamWriter streamWriter (&file);
streamWriter.setAutoFormatting (true);
streamWriter.writeStartDocument ();
streamWriter.writeStartElement ("opml");
streamWriter.writeAttribute ("version", "1.0");
streamWriter.writeStartElement ("head");
streamWriter.writeStartElement ("text");
streamWriter.writeEndElement ();
streamWriter.writeEndElement ();
streamWriter.writeStartElement ("body");
streamWriter.writeStartElement ("outline");
streamWriter.writeAttribute ("text", "Live Bookmarks");
Q_FOREACH (const QVariant& hRowVar, opmlData)
{
streamWriter.writeStartElement ("outline");
QMap<QString, QVariant> hRow = hRowVar.toMap ();
QXmlStreamAttributes attr;
attr.append ("title", hRow ["Title"].toString ());
attr.append ("htmlUrl", hRow ["SiteUrl"].toString ());
attr.append ("xmlUrl", hRow ["FeedUrl"].toString ());
attr.append ("text", hRow ["Title"].toString ());
streamWriter.writeAttributes (attr);
streamWriter.writeEndElement ();
}