本文整理汇总了C++中QDomAttr::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomAttr::setValue方法的具体用法?C++ QDomAttr::setValue怎么用?C++ QDomAttr::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomAttr
的用法示例。
在下文中一共展示了QDomAttr::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addHistory
void PathMapper::addHistory(const QString &localpath, const QString &serverpath, bool saveinproject)
{
bool exists = false;
for (unsigned int cnt = 0; cnt < m_serverlist.count() && !exists; cnt++ )
if(m_serverlist[cnt] == serverpath && m_locallist[cnt] == localpath)
exists = true;
if(!exists)
{
if(saveinproject)
{
QDomNode node = pathMapperNode();
QDomNode newnode = Project::ref()->dom()->createElement("mapping");
QDomAttr serverattr = Project::ref()->dom()->createAttribute("serverpath");
serverattr.setValue(serverpath);
QDomAttr localattr = Project::ref()->dom()->createAttribute("localpath");
localattr.setValue(localpath);
newnode.attributes().setNamedItem(serverattr);
newnode.attributes().setNamedItem(localattr);
node = node.namedItem("mappings");
node.insertAfter(newnode, node.lastChild());
}
m_serverlist.append(serverpath);
m_locallist.append(localpath);
}
}
示例2: 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);
}
}
}
示例3: writeXml
// 将销售记录写入文档
void Widget::writeXml()
{
// 先从文件读取
if (docRead()) {
QString currentDate = getDateTime(Date);
QDomElement root = doc.documentElement();
// 根据是否有日期节点进行处理
if (!root.hasChildNodes()) {
QDomElement date = doc.createElement(QString("日期"));
QDomAttr curDate = doc.createAttribute("date");
curDate.setValue(currentDate);
date.setAttributeNode(curDate);
root.appendChild(date);
createNodes(date);
} else {
QDomElement date = root.lastChild().toElement();
// 根据是否已经有今天的日期节点进行处理
if (date.attribute("date") == currentDate) {
createNodes(date);
} else {
QDomElement date = doc.createElement(QString("日期"));
QDomAttr curDate = doc.createAttribute("date");
curDate.setValue(currentDate);
date.setAttributeNode(curDate);
root.appendChild(date);
createNodes(date);
}
}
// 写入到文件
docWrite();
}
}
示例4: writeConfig
void PrefPortaudio::writeConfig()
{
/* We can do better error control here, can't we? */
ISettings *_settings = new ISettings();
QDomElement cfg = _settings->getConfigNode("portaudio.conf");
QDomNodeList nl = cfg.elementsByTagName("param");
for (int i = 0; i < nl.count(); i++) {
QDomAttr var = nl.at(i).toElement().attributeNode("name");
QDomAttr val = nl.at(i).toElement().attributeNode("value");
if (var.value() == "indev") {
val.setValue(QString::number(_ui->PaIndevCombo->itemData(_ui->PaIndevCombo->currentIndex(), Qt::UserRole).toInt()));
}
if (var.value() == "outdev") {
val.setValue(QString::number(_ui->PaOutdevCombo->itemData(_ui->PaOutdevCombo->currentIndex(), Qt::UserRole).toInt()));
}
if (var.value() == "ringdev") {
val.setValue(QString::number(_ui->PaRingdevCombo->itemData(_ui->PaRingdevCombo->currentIndex(), Qt::UserRole).toInt()));
}
if (var.value() == "ring-file") {
val.setValue(_ui->PaRingFileEdit->text());
}
if (var.value() == "ring-interval") {
val.setValue(QString::number(_ui->PaRingIntervalSpin->value()));
}
if (var.value() == "hold-file") {
val.setValue(_ui->PaHoldFileEdit->text());
}
if (var.value() == "cid-name") {
val.setValue(_ui->PaCallerIdNameEdit->text());
}
if (var.value() == "cid-num") {
val.setValue(_ui->PaCallerIdNumEdit->text());
}
if (var.value() == "sample-rate") {
val.setValue(_ui->PaSampleRateEdit->text());
}
if (var.value() == "codec-ms") {
val.setValue(_ui->PaCodecMSEdit->text());
}
/* Not used currently
if (var.value() == "dialplan") {
val.setValue();
}
if (var.value() == "timer-name") {
val.setValue();
}*/
}
/* Save the config to the file */
_settings->setConfigNode(cfg, "portaudio.conf");
}
示例5: modify
void SvgImage::modify(const QString &tag, const QString &id, const QString &attribute,
const QString &value)
{
bool modified = false;
QDomNodeList nodeList = m_svgDocument.elementsByTagName( tag );
for ( int i = 0; i < nodeList.count(); ++i )
{
QDomNode node = nodeList.at( i );
QDomNamedNodeMap attributes = node.attributes();
if ( checkIDAttribute( attributes, id ) )
{
QDomNode attrElement = attributes.namedItem( attribute );
if ( attrElement.isAttr() )
{
QDomAttr attr = attrElement.toAttr();
attr.setValue( value );
modified = true;
}
}
}
if ( modified )
{
m_updateNeeded = true;
update();
}
}
示例6: 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);
}
示例7:
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);
}
示例8: 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("添加成功"));
}
示例9: 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;
}
示例10: 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;
}
示例11: addMailInfo
int ConfigFileClass::addMailInfo(QString id,QString mailAddr,QString password)
{
QString ls,ls2;
if(searchMailInfo(id,&ls,&ls2))return false;
QDomElement rootE=this->configDoc.firstChildElement(QString("Root"));
QDomElement mailListE=rootE.firstChildElement(QString("MailList"));
QDomElement newMailInfoE=this->configDoc.createElement("MailInfo");
QDomAttr newId = this->configDoc.createAttribute("id");
QDomElement newMailAddrE = this->configDoc.createElement("MailAddr");
QDomElement newPasswordE = this->configDoc.createElement(tr("PassWord"));
QDomText text;
newId.setValue(id);
newMailInfoE.setAttributeNode(newId);
text = this->configDoc.createTextNode(mailAddr);
newMailAddrE.appendChild(text);
text = this->configDoc.createTextNode(password);
newPasswordE.appendChild(text);
newMailInfoE.appendChild(newMailAddrE);
newMailInfoE.appendChild(newPasswordE);
mailListE.appendChild(newMailInfoE);
return true;
}
示例12: sipReleaseType
static PyObject *meth_QDomAttr_setValue(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
const QString* a0;
int a0State = 0;
QDomAttr *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QDomAttr, &sipCpp, sipType_QString,&a0, &a0State))
{
sipCpp->setValue(*a0);
sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QDomAttr, sipName_setValue, doc_QDomAttr_setValue);
return NULL;
}
示例13: createNodes
// 创建节点
void Widget::createNodes(QDomElement &date)
{
QDomElement time = doc.createElement(QString("时间"));
QDomAttr curTime = doc.createAttribute("time");
curTime.setValue(getDateTime(Time));
time.setAttributeNode(curTime);
date.appendChild(time);
QDomElement type = doc.createElement(QString("类型"));
QDomElement brand = doc.createElement(QString("品牌"));
QDomElement price = doc.createElement(QString("单价"));
QDomElement num = doc.createElement(QString("数量"));
QDomElement sum = doc.createElement(QString("金额"));
QDomText text;
text = doc.createTextNode(QString("%1")
.arg(ui->sellTypeComboBox->currentText()));
type.appendChild(text);
text = doc.createTextNode(QString("%1")
.arg(ui->sellBrandComboBox->currentText()));
brand.appendChild(text);
text = doc.createTextNode(QString("%1")
.arg(ui->sellPriceLineEdit->text()));
price.appendChild(text);
text = doc.createTextNode(QString("%1")
.arg(ui->sellNumSpinBox->value()));
num.appendChild(text);
text = doc.createTextNode(QString("%1")
.arg(ui->sellSumLineEdit->text()));
sum.appendChild(text);
time.appendChild(type);
time.appendChild(brand);
time.appendChild(price);
time.appendChild(num);
time.appendChild(sum);
}
示例14: receiveSaveRequest
void Competences::receiveSaveRequest()
{
QDomElement elem;
QDomAttr a;
elem = xmlManager.getCompetences().firstChildElement("pointsADepenser");
a = elem.attributeNode("value");
a.setValue(aDepenser->text());
elem = xmlManager.getCompetences().firstChildElement("degreMaitriseMax");
a = elem.attributeNode("deClasse");
a.setValue(degreMaitriseMaxI->text());
a = elem.attributeNode("inconnue");
a.setValue(degreMaitriseMaxN->text());
elem = xmlManager.getCompetences().firstChildElement("liste");
while(!elem.firstChild().isNull()) // Suppression des anciennes lignes
{
elem.removeChild(elem.firstChild());
}
for(int i=0;i<table->rowCount();i++)
{
QDomElement ligneTableau = xmlManager.getDoc().createElement("ligne");
ligneTableau.setAttribute("numero",i);
elem.appendChild(ligneTableau);
QDomElement elemLigne;
// compétence de classe ou non
elemLigne = xmlManager.getDoc().createElement("deClasse");
if(static_cast<QCheckBox*>(table->cellWidget(i,0))->isChecked())
elemLigne.setAttribute("value","oui");
else
elemLigne.setAttribute("value","non");
ligneTableau.appendChild(elemLigne);
// nom de la compétence
elemLigne = xmlManager.getDoc().createElement("nom");
elemLigne.removeChild(elemLigne.firstChild());
QDomText valeur = xmlManager.getDoc().createTextNode(static_cast<QLabel*>(table->cellWidget(i,2))->text());
elemLigne.appendChild(valeur);
ligneTableau.appendChild(elemLigne);
// degré de maitrise
elemLigne = xmlManager.getDoc().createElement("degreMaitrise");
if(table->item(i,6) == NULL)
elemLigne.setAttribute("value","");
else
elemLigne.setAttribute("value",table->item(i,6)->text());
ligneTableau.appendChild(elemLigne);
// modificateurs divers
elemLigne = xmlManager.getDoc().createElement("modDivers");
if(table->item(i,7) == NULL)
elemLigne.setAttribute("value","");
else
elemLigne.setAttribute("value",table->item(i,7)->text());
ligneTableau.appendChild(elemLigne);
}
emit saveDone();
}
示例15: 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);
}