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


C++ QDomDocument::createAttribute方法代码示例

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


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

示例1: save

void Properties::save(QDomDocument &doc, QDomElement &parent)
{               
  QDomElement propertiesElem = doc.createElement(XML_TAGNAME.c_str());
  parent.appendChild(propertiesElem);

  QDomAttr propertieAttr;
  for (std::map<std::string, Property*>::iterator it = _properties.begin(); it != _properties.end(); ++it)
  {    
    // to save string lists, we save each value the format property_name[index]
    const std::vector<std::string> &lst = it->second->valueStrList();
    if(lst.size()>1)
    {
      
      for(unsigned int i=0;i<lst.size(); i++)
      {
        QString index;
        index.sprintf("%i",i);
        propertieAttr = doc.createAttribute(QString(it->second->name().c_str()).replace(' ', WHITESPACE_REPLACEMENT)+index);
        propertieAttr.setValue(lst[i].c_str());
        propertiesElem.setAttributeNode(propertieAttr);
      }
    }
    else
    {
      propertieAttr = doc.createAttribute(QString(it->second->name().c_str()).replace(' ', WHITESPACE_REPLACEMENT));
      propertieAttr.setValue(it->second->valueStr().c_str());
      propertiesElem.setAttributeNode(propertieAttr);
    }
  }    
}
开发者ID:foogywoo,项目名称:drone,代码行数:30,代码来源:Properties.cpp

示例2: file

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QFile file("test.xml");
    if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate ))
        return;
    else
        qDebug()<<"ths file is existing!";
    QDomDocument doc;
    QDomText text;
    QDomProcessingInstruction instruction;
    instruction=doc.createProcessingInstruction("xml", "version = \'1.0\'");
    doc.appendChild(instruction);
    QDomElement school=doc.createElement("school");


    doc.appendChild(school);

    QDomElement schoolGuangMing=doc.createElement("schoolGuangMing");
    school.appendChild(schoolGuangMing);

    QDomElement grate1=doc.createElement("grate1");
    text=doc.createTextNode("一年级");
    grate1.appendChild(text);
    schoolGuangMing.appendChild(grate1);

    QDomElement student= doc.createElement("student1");
    QDomAttr name=doc.createAttribute("name");
    name.setValue("李明");
    QDomAttr number=doc.createAttribute("number");
    number.setValue("0x12313");
    student.setAttributeNode(name);
    student.setAttributeNode(number);
    schoolGuangMing.appendChild(student);


    QDomElement grate2=doc.createElement("grate2");
    text=doc.createTextNode("二年级");
    grate2.appendChild(text);
    schoolGuangMing.appendChild(grate2);

    QDomElement grate3=doc.createElement("grate3");
    text=doc.createTextNode("三年级");
    grate3.appendChild(text);
    schoolGuangMing.appendChild(grate3);

    QDomElement grate4=doc.createElement("grate4");
    text=doc.createTextNode("四年级");
    grate4.appendChild(text);
    schoolGuangMing.appendChild(grate4);

    QTextStream out( &file );

           doc.save( out, 7 );

        file.close();
}
开发者ID:squirrelClare,项目名称:algorithm_cplusplus,代码行数:60,代码来源:mainwindow.cpp

示例3: createAttribute

QDomAttr QDomDocumentProto::createAttribute(const QString& name)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->createAttribute(name);
    return QDomAttr();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: internalSave

void Gear_ListBox::internalSave(QDomDocument &doc, QDomElement &gearElem)
{
  std::ostringstream strValue;

  strValue << getValue();
  QDomAttr attrListBoxPos = doc.createAttribute("ListBoxPos");
  attrListBoxPos.setValue(strValue.str().c_str());
  gearElem.setAttributeNode(attrListBoxPos);

}
开发者ID:foogywoo,项目名称:drone,代码行数:10,代码来源:Gear_ListBox.cpp

示例5:

void Schema::Connection::save(QDomDocument &doc, QDomElement &parent)
{
  QDomElement connectionElem = doc.createElement("Connection");
  parent.appendChild(connectionElem);

  QDomAttr gearA = doc.createAttribute("GearA");
  gearA.setValue(_gearA.c_str());
  connectionElem.setAttributeNode(gearA);

  QDomAttr input = doc.createAttribute("Input");
  input.setValue(_input.c_str());
  connectionElem.setAttributeNode(input);

  QDomAttr gearB = doc.createAttribute("GearB");
  gearB.setValue(_gearB.c_str());
  connectionElem.setAttributeNode(gearB);

  QDomAttr output = doc.createAttribute("Output");
  output.setValue(_output.c_str());
  connectionElem.setAttributeNode(output);

}
开发者ID:foogywoo,项目名称:drone,代码行数:22,代码来源:Schema.cpp

示例6: on_btn_select_clicked

void MainWindow::on_btn_select_clicked()
{
    ui->listWidget->clear();
    ui->listWidget->addItem(tr("无法添加"));
    QFile file("my.xml");
    if(!file.open(QIODevice::ReadOnly()))
    {
        return;
    }
    QDomDocument doc;
    if(!doc.setContent(&file))
    {
        file.close();
        return ;
    }
    file.close();

    QDomElement root = doc.documentElement();
    QDomElement book = doc.documentElement(tr("图书"));
    QDomAttr id = doc.createAttribute(tr("编号"));
    QDomElement title = doc.documentElement(tr("书名"));
    QDomElement author = doc.documentElement(tr("作者"));
    QDomText text;

    QString num = root.lastChild().toElement().attribute(tr("编号"));
    int count = num.toInt() +1;
    id.setValue(QString::number(count));
    book.setAttributeNode(id);
    text = doc.createTextNode(ui->lineEdit_name->text());
    title.appendChild(text);
    text = doc.createTextNode(ui->lineEdit_author->text());
    author.appendChild(text);
    book.appendChild(title);
    book.appendChild(author);
    root.appendChild(book);
    if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
    {
        return;
    }
    QTextStream out(&file);
    doc.save(out, 4);
    file.close();
    ui->listWidget->clear();
    ui->listWidget->addItem(tr("添加成功"));
}
开发者ID:gessd,项目名称:my_qt,代码行数:45,代码来源:mainwindow.cpp

示例7: getBlocks

QDomElement ExerciseWindow::getBlocks(const FCWidget *fc, QDomDocument &doc, QString Name)
{
    int n = fc->layout()->count();
    int i = 0;
    QDomElement domElement = doc.createElement(Name);
    while (i < n) {
        QDomElement block;
        QDomAttr attr = doc.createAttribute("text");
        QString tag = fc->layout()->itemAt(i)->widget()->metaObject()->className();
        if (tag != "FCLine" && tag != "FCLeftLine" && tag != "RightLine") {
            block = doc.createElement(tag);
            FCWidget *widget = (FCWidget*)fc->layout()->itemAt(i)->widget();
            attr.setValue(widget->getText());
            block.setAttributeNode(attr);
            domElement.appendChild(block);
            if (tag == "FCDivarWidget") {
                FCDivarWidget *divar = (FCDivarWidget*)widget;
                QDomElement left = getBlocks(divar->getRightLine(), doc, "Left");
                QDomElement right = getBlocks(divar->getLeftLine(), doc, "Right");
                block.appendChild(left);
                block.appendChild(right);
            }
            else if (tag == "FCPrefixCycleWidget") {
                FCPrefixCycleWidget *cycle = (FCPrefixCycleWidget*)widget;
                QDomElement body = getBlocks(cycle->getCycleBody(), doc, "Body");
                block.appendChild(body);
            }
            else if (tag == "FCPostfixCycleWidget") {
                FCPostfixCycleWidget *cycle = (FCPostfixCycleWidget*)widget;
                QDomElement body = getBlocks(cycle->getCycleBody(), doc, "Body");
                block.appendChild(body);
            }
            else if (tag == "FCParameterCycleWidget") {
                FCParameterCycleWidget *cycle = (FCParameterCycleWidget*)widget;
                QDomElement body = getBlocks(cycle->getCycleBody(), doc, "Body");
                block.appendChild(body);
            }
        }
        i++;
    }
    return domElement;
}
开发者ID:MrBentCode,项目名称:FlowChart_trainer,代码行数:42,代码来源:exercisewindow.cpp

示例8: makeElement

QDomElement makeElement(      QDomDocument& domDoc,
                        const QString&      strName,
                        const QString&      strAttr = QString::null,
                        const QString&      strText = QString::null
                       )
{
    QDomElement domElement = domDoc.createElement(strName);

    if (!strAttr.isEmpty()) {
        QDomAttr domAttr = domDoc.createAttribute("number");
        domAttr.setValue(strAttr);
        domElement.setAttributeNode(domAttr);
    }

    if (!strText.isEmpty()) {
        QDomText domText = domDoc.createTextNode(strText);
        domElement.appendChild(domText);
    }
    return domElement;
}
开发者ID:LibertaSoft,项目名称:ConvertToDba,代码行数:20,代码来源:writetodbaformat.cpp

示例9: saveDegree

void XmlDataPersistance::saveDegree(Degree *degree, QDomElement &element, QDomDocument &dom)
{
    QDomElement degreeElement = dom.createElement("item");
    degreeElement.setAttribute("type",degree->type());
    element.appendChild(degreeElement);

    QDomElement titleElement = dom.createElement("titre");
    titleElement.appendChild(dom.createTextNode(degree->title()));
    degreeElement.appendChild(titleElement);

    QDomElement typeElement = dom.createElement("type");
    typeElement.appendChild(dom.createTextNode(degree->type()));
    degreeElement.appendChild(typeElement);

    const QList<const Uv*> &uvs = degree->uvs();
    for(int i = 0; i < uvs.size(); i++)
    {
        QDomElement uvElement = dom.createElement("uv");
        uvElement.appendChild(dom.createTextNode(uvs.at(i)->code()));
        degreeElement.appendChild(uvElement);
    }

    const QMap<QString,int> &quotas = degree->quotas();
    QMapIterator<QString,int> it(quotas);
    while(it.hasNext())
    {
        it.next();
        QDomElement quotaElement = dom.createElement("quota");
        QDomAttr cat = dom.createAttribute("categorie");
        cat.setNodeValue(it.key());
        quotaElement.setAttributeNode(cat);
        quotaElement.appendChild(dom.createTextNode(QString::number(it.value())));
        degreeElement.appendChild(quotaElement);
    }

    const QList<Degree*> &children = degree->children();
    for(int i = 0; i < children.size(); i++)
        saveDegree(children.at(i),degreeElement,dom);
}
开发者ID:cmercier,项目名称:UTProfiler,代码行数:39,代码来源:xmldatapersistance.cpp

示例10: makeElement

QDomElement SettingsObj::makeElement(QDomDocument &dom_doc,
                                     const QString &name,
                                     const QString &attr,
                                     const QString &text)
{
    QDomElement dom_element = dom_doc.createElement(name);

    if(!attr.isEmpty())
    {
        QDomAttr dom_attr = dom_doc.createAttribute("id");
        dom_attr.setValue(attr);
        dom_element.setAttributeNode(dom_attr);
    }

    if(!text.isEmpty())
    {
        QDomText dom_text = dom_doc.createTextNode(text);
        dom_element.appendChild(dom_text);
    }

    return dom_element;
}
开发者ID:BACuTPOH,项目名称:r245,代码行数:22,代码来源:settings_obj.cpp

示例11: saveXmlAttribute

void RedisConnectionConfig::saveXmlAttribute(QDomDocument & document, QDomElement & root, const QString& name, const QString& value)
{
    QDomAttr attr = document.createAttribute(name);
    attr.setValue(value);
    root.setAttributeNode(attr);
}
开发者ID:KingLee2015,项目名称:RedisDesktopManager,代码行数:6,代码来源:RedisConnectionConfig.cpp

示例12: main

int main(int argc, char *argv[])

{QCoreApplication a(argc,argv);

       QFile file( "domwrite.kdevelop" );

       if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) ){
              return 0;
       }else{
           qDebug()<<"OPEN!";
       }



       QDomDocument doc;

       QDomText text;

       QDomElement element;

       QDomProcessingInstruction instruction;

       instruction = doc.createProcessingInstruction( "xml", "version = \'1.0\'" );

       doc.appendChild( instruction );

       QDomElement root = doc.createElement( "kdevelop" );

       doc.appendChild( root );

       QDomElement general = doc.createElement( "general" );

       root.appendChild( general );



       element = doc.createElement( "author" );

       text = doc.createTextNode( "zeki" );



       general.appendChild( element );
        element.appendChild( text );



       element = doc.createElement( "email" );

       text = doc.createTextNode( "[email protected]" );

       element.appendChild( text );

       general.appendChild( element );



       element = doc.createElement( "version" );

       text = doc.createTextNode( "$VERSION" );

       element.appendChild( text );

       general.appendChild( element );



       QDomElement keywords = doc.createElement( "keywords" );

       element = doc.createElement( "keyword" );

       text = doc.createTextNode( "C++" );

       element.appendChild( text );

       keywords.appendChild( element );

       general.appendChild( keywords );



       element = doc.createElement( "ignoreparts" );

       general.appendChild( element );



       QDomElement kdevfileview = doc.createElement( "kdevfileview" );

       QDomElement groups = doc.createElement( "groups" );

       element = doc.createElement( "group" );

       QDomAttr pattern = doc.createAttribute( "pattern" );

       pattern.setValue( "*.cpp;*.cxx;*.h" );

       QDomAttr name = doc.createAttribute( "name" );

       name.setValue( "Sources" );
//.........这里部分代码省略.........
开发者ID:squirrelClare,项目名称:algorithm_cplusplus,代码行数:101,代码来源:main.cpp

示例13: initschedulexmldata

void schedulexmldata::initschedulexmldata()
{
    QFile file("/home/user/.scheduledata.xml");
    if( !file.open(QIODevice::ReadWrite))
        return;
    QFileInfo fileinfo(file);
    if(fileinfo.size() == 0){
        file.close();
        QDomDocument doc;
        QDomProcessingInstruction instruction;
        instruction = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
        doc.appendChild(instruction);

        QDomElement root = doc.createElement(QString("scheduledata"));
        doc.appendChild(root);
        QDomText text;

        QDomElement scheduledate = doc.createElement(QString("scheduledate"));
        root.appendChild(scheduledate);
        QDomAttr scheduledateattr = doc.createAttribute(QString("scheduledateattr"));
        scheduledateattr.setValue(QString("00000000"));
        scheduledate.setAttributeNode(scheduledateattr);

        QDomElement schedule = doc.createElement(QString("schedule"));
        scheduledate.appendChild(schedule);
        QDomAttr scheduleid = doc.createAttribute(QString("id"));
        scheduleid.setValue(QString("0"));
        schedule.setAttributeNode(scheduleid);

        QDomElement theme = doc.createElement(QString("theme"));
        text = doc.createTextNode(QString(""));
        theme.appendChild(text);
        schedule.appendChild(theme);
        QDomElement occurtime = doc.createElement(QString("occurtime"));
        text = doc.createTextNode(QString(""));
        occurtime.appendChild(text);
        schedule.appendChild(occurtime);
        QDomElement occuraddress = doc.createElement(QString("occuraddress"));
        text = doc.createTextNode(QString(""));
        schedule.appendChild(occuraddress);
//        QDomElement remindtime = doc.createElement(QString("remindtime"));
//        text = doc.createTextNode(QString(""));
//        remindtime.appendChild(text);
//        schedule.appendChild(remindtime);
//        QDomElement remindway = doc.createElement(QString("remindway"));
//        text = doc.createTextNode(QString(""));
//        remindway.appendChild(text);
//        schedule.appendChild(remindway);
//        QDomElement remindsequence = doc.createElement(QString("remindsequence"));
//        text = doc.createTextNode(QString(""));
//        remindsequence.appendChild(text);
//        schedule.appendChild(remindsequence);
        QDomElement eventrepeat = doc.createElement(QString("eventrepeat"));
        text = doc.createTextNode(QString(""));
        eventrepeat.appendChild(text);
        schedule.appendChild(eventrepeat);
        QDomElement detail = doc.createElement(QString("detail"));
        text = doc.createTextNode(QString(""));
        detail.appendChild(text);
        schedule.appendChild(detail);

        if( !file.open(QIODevice::WriteOnly | QIODevice::Truncate)) return;
        QTextStream out(&file);
        doc.save(out, 4);
        file.close();
    }else{
        file.close();
    }
}
开发者ID:autumnViolet,项目名称:love,代码行数:69,代码来源:schedulexmldata.cpp

示例14: addschedulexmldata

void schedulexmldata::addschedulexmldata(QString tmpscheduledate, QString tmpid, QString tmptheme, QString tmpoccurtime, QString tmpoccuraddress,
                                         /*QString tmpremindtime, QString tmpremindway, QString tmpremindsequence,*/ QString tmpeventrepeat, QString tmpdetail)
{
    QFile file("/home/user/.scheduledata.xml");
    if(!file.open(QIODevice::ReadOnly))  return;
    QDomDocument doc;
    if(!doc.setContent(&file)){
        file.close();
        return;
    }
    file.close();

    QDomText text;

    QDomElement root = doc.documentElement();
    QDomElement scheduledate = doc.createElement(QString("scheduledate"));
    QDomAttr scheduledateattr = doc.createAttribute(QString("scheduledateattr"));
    scheduledate.setAttributeNode(scheduledateattr);
    QDomElement schedule = doc.createElement(QString("schedule"));

    QDomNode n = root.firstChild();
    if(n.toElement().attribute(QString("scheduledateattr")) == "00000000"){
        root.removeChild(n);
        root.appendChild(scheduledate);
        scheduledateattr.setValue(tmpscheduledate);
        scheduledate.appendChild(schedule);
    }else{
        bool scheduledateisexistence = false;
        while(!n.isNull()){
            if((n.previousSibling().toElement().attribute(QString("scheduledateattr")) <  tmpscheduledate) &&( tmpscheduledate < n.toElement().attribute(QString("scheduledateattr")))){
                root.insertBefore(scheduledate, n);
                scheduledateattr.setValue(tmpscheduledate);
                scheduledate.appendChild(schedule);
                scheduledateisexistence = true;
            }else if(tmpscheduledate == n.toElement().attribute(QString("scheduledateattr"))){
                n.toElement().appendChild(schedule);
                scheduledateisexistence = true;
            }
            n = n.nextSibling();
        }
        if(!scheduledateisexistence){
            root.appendChild(scheduledate);
            scheduledateattr.setValue(tmpscheduledate);
            scheduledate.appendChild(schedule);
        }
    }


    if(tmpid == "-10"){
        QDomNode nn = root.firstChild();
        while(!nn.isNull()){
            if(tmpscheduledate == nn.toElement().attribute(QString("scheduledateattr"))){
                QDomNodeList schedulelist = nn.toElement().elementsByTagName(QString("schedule"));
                tmpid.setNum(schedulelist.count() - 1);
                qDebug() << tmpid;
            }
            nn = nn.nextSibling();
        }
    }

    QDomAttr scheduleid = doc.createAttribute(QString("id"));
    scheduleid.setValue(QString(tmpid));
    schedule.setAttributeNode(scheduleid);
    QDomElement theme = doc.createElement(QString("theme"));
    text = doc.createTextNode(QString(tmptheme));
    theme.appendChild(text);
    schedule.appendChild(theme);
    QDomElement occurtime = doc.createElement(QString("occurtime"));
    text = doc.createTextNode(QString(tmpoccurtime));
    occurtime.appendChild(text);
    schedule.appendChild(occurtime);
    QDomElement occuraddress = doc.createElement(QString("occuraddress"));
    text = doc.createTextNode(QString(tmpoccuraddress));
    occuraddress.appendChild(text);
    schedule.appendChild(occuraddress);
//    QDomElement remindtime = doc.createElement(QString("remindtime"));
//    text = doc.createTextNode(QString(tmpremindtime));
//    remindtime.appendChild(text);
//    schedule.appendChild(remindtime);
//    QDomElement remindway = doc.createElement(QString("remindway"));
//    text = doc.createTextNode(QString(tmpremindway));
//    remindway.appendChild(text);
//    schedule.appendChild(remindway);
//    QDomElement remindsequence = doc.createElement(QString("remindsequence"));
//    text = doc.createTextNode(QString(tmpremindsequence));
//    remindsequence.appendChild(text);
//    schedule.appendChild(remindsequence);
    QDomElement eventrepeat = doc.createElement(QString("eventrepeat"));
    text = doc.createTextNode(QString(tmpeventrepeat));
    eventrepeat.appendChild(text);
    schedule.appendChild(eventrepeat);
    QDomElement detail = doc.createElement(QString("detail"));
    text = doc.createTextNode(QString(tmpdetail));
    detail.appendChild(text);
    schedule.appendChild(detail);

    if( !file.open(QIODevice::WriteOnly | QIODevice::Truncate)) return;
    QTextStream out(&file);
    doc.save(out, 4);
    file.close();
//.........这里部分代码省略.........
开发者ID:autumnViolet,项目名称:love,代码行数:101,代码来源:schedulexmldata.cpp

示例15: saveMap

void TwoDRenderer::saveMap( QString filePath )
{
	QFile file( filePath );
	if( false == file.open(QFile::WriteOnly) )
		return;
		
	#define MAP_STRUCTURE "<?xml version=\"1.0\" ?>" \
								"<delleriumMap>" \
									"<walls></walls>" \
									"<bushes></bushes>" \
									"<me>" \
										"<balls></balls>" \
										"<targets></targets>" \
									"</me>" \
									"<enemy>" \
										"<balls></balls>" \
										"<targets></targets>" \
									"</enemy>" \
								"</delleriumMap>"
	
	// here we build the XML strucuture for the map
	QDomDocument domDocument;
	domDocument.setContent( QString(MAP_STRUCTURE) );

	QDomNode rootNode = domDocument.documentElement();

	QDomNode wallsNode = getChildByName( rootNode, "walls" );
	QDomNode bushesNode = getChildByName( rootNode, "bushes" );

	QDomNode meBallsNode = getChildByName( getChildByName(rootNode,"me"), "balls" );
	QDomNode meTargetsNode = getChildByName( getChildByName(rootNode,"me"), "targets" );
	
	QDomNode enemyBallsNode = getChildByName( getChildByName(rootNode,"enemy"), "balls" );
	QDomNode enemyTargetsNode = getChildByName( getChildByName(rootNode,"enemy"), "targets" );

	QList<QGraphicsItem*> gameObjects = _scene->items();
	foreach( QGraphicsItem* item, gameObjects )
	{
		GameObject* gameObject = static_cast<GameObject*>( item );
		if( 0 != gameObject )
		{
			switch( gameObject->getObjectType() )
			{
				case GameObject::ObjectWall:
					{
						QDomElement element = domDocument.createElement( "wall" );
						QDomAttr attributeX = domDocument.createAttribute( "x" ); attributeX.setValue( QString("%1").arg(gameObject->x()) );
						QDomAttr attributeY = domDocument.createAttribute( "y" ); attributeY.setValue( QString("%1").arg(gameObject->y()) );
						element.setAttributeNode( attributeX );
						element.setAttributeNode( attributeY );
						wallsNode.appendChild( element );
					}
					break;
					
				case GameObject::ObjectBush:
					{
						QDomElement element = domDocument.createElement( "bush" );
						QDomAttr attributeX = domDocument.createAttribute( "x" ); attributeX.setValue( QString("%1").arg(gameObject->x()) );
						QDomAttr attributeY = domDocument.createAttribute( "y" ); attributeY.setValue( QString("%1").arg(gameObject->y()) );
						element.setAttributeNode( attributeX );
						element.setAttributeNode( attributeY );
			
						bushesNode.appendChild( element );
					}
					break;
		
				case GameObject::ObjectBall:
					{
						QDomElement element = domDocument.createElement( "ball" );
						QDomAttr attributeX = domDocument.createAttribute( "x" ); attributeX.setValue( QString("%1").arg(gameObject->x()) );
						QDomAttr attributeY = domDocument.createAttribute( "y" ); attributeY.setValue( QString("%1").arg(gameObject->y()) );
						element.setAttributeNode( attributeX );
						element.setAttributeNode( attributeY );

						meBallsNode.appendChild( element );
					}
					break;
					
				case GameObject::ObjectTarget:
					{
						QDomElement element = domDocument.createElement( "target" );
						QDomAttr attributeX = domDocument.createAttribute( "x" ); attributeX.setValue( QString("%1").arg(gameObject->x()) );
						QDomAttr attributeY = domDocument.createAttribute( "y" ); attributeY.setValue( QString("%1").arg(gameObject->y()) );
						element.setAttributeNode( attributeX );
						element.setAttributeNode( attributeY );

						meTargetsNode.appendChild( element );
					}
					break;
		
				case GameObject::ObjectEnemyBall:
					{
						QDomElement element = domDocument.createElement( "ball" );
						QDomAttr attributeX = domDocument.createAttribute( "x" ); attributeX.setValue( QString("%1").arg(gameObject->x()) );
						QDomAttr attributeY = domDocument.createAttribute( "y" ); attributeY.setValue( QString("%1").arg(gameObject->y()) );
						element.setAttributeNode( attributeX );
						element.setAttributeNode( attributeY );

						enemyBallsNode.appendChild( element );
					}
//.........这里部分代码省略.........
开发者ID:nic0lae,项目名称:freebsddistro,代码行数:101,代码来源:2drenderer.cpp


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