本文整理汇总了C++中QDomText::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomText::setData方法的具体用法?C++ QDomText::setData怎么用?C++ QDomText::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomText
的用法示例。
在下文中一共展示了QDomText::setData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkVerifyResponse
void UrlResolverTest::checkVerifyResponse(){
QDomDocument doc("foo");
QDomElement root = doc.createElement("foo");
doc.appendChild(root);
QDomElement action = doc.createElement("action");
root.appendChild(action);
action.appendChild(doc.createTextNode("register"));
QDomElement deviceId = doc.createElement("deviceId");
root.appendChild(deviceId);
deviceId.appendChild(doc.createTextNode("deadbeef-dead-beef-dead"));
QDomElement protocolVersion = doc.createElement("protocolVersion");
root.appendChild(protocolVersion);
QDomText protocolVersionText = doc.createTextNode(SSU_PROTOCOL_VERSION);
protocolVersion.appendChild(protocolVersionText);
QVERIFY(ssu.verifyResponse(&doc));
protocolVersionText.setData(SSU_PROTOCOL_VERSION ".invalid");
QVERIFY2(!ssu.verifyResponse(&doc),
"Ssu::verifyResponse() should fail when protocolVersion does not match SSU_PROTOCOL_VERSION");
}
示例2: loadWrongHeadAttributes
void FixtureGroup_Test::loadWrongHeadAttributes()
{
QDomDocument doc;
QDomElement root = doc.createElement("FixtureGroup");
root.setAttribute("ID", "12345");
doc.appendChild(root);
QDomElement head = doc.createElement("Head");
head.setAttribute("X", "Seppo");
head.setAttribute("Y", "0");
head.setAttribute("Fixture", "42");
QDomText headText = doc.createTextNode("0");
head.appendChild(headText);
root.appendChild(head);
FixtureGroup grp(m_doc);
QVERIFY(grp.loadXML(root) == true);
QCOMPARE(grp.headHash().size(), 0);
head.setAttribute("X", "0");
head.setAttribute("Y", "Pertti");
QVERIFY(grp.loadXML(root) == true);
QCOMPARE(grp.headHash().size(), 0);
head.setAttribute("Y", "0");
head.setAttribute("Fixture", "Jorma");
QVERIFY(grp.loadXML(root) == true);
QCOMPARE(grp.headHash().size(), 0);
head.setAttribute("Fixture", "42");
headText.setData("Esko");
QVERIFY(grp.loadXML(root) == true);
QCOMPARE(grp.headHash().size(), 0);
headText.setData("0");
QVERIFY(grp.loadXML(root) == true);
QCOMPARE(grp.headHash().size(), 1);
}
示例3: setDataSource
void QgsProjectBadLayerHandler::setDataSource( QDomNode &layerNode, const QString &dataSource )
{
QDomNode dataSourceNode = layerNode.namedItem( QStringLiteral( "datasource" ) );
QDomElement dataSourceElement = dataSourceNode.toElement();
QDomText dataSourceText = dataSourceElement.firstChild().toText();
QgsDebugMsg( "datasource changed from " + dataSourceText.data() );
dataSourceText.setData( dataSource );
QgsDebugMsg( "to " + dataSourceText.data() );
}
示例4: kDebug
void Select1::saveData()
{
kDebug() <<"Select1::saveData()";
kDebug() << ref().toString();
kDebug() <<"Context:" << context().nodeName();
Reference::Segment s;
if( ref().segments().size() > 0 )
s = ref().segments().last();
QString txt;
if( mProperties->appearance == Full ) {
for( int i = 0; i < mRadioButtons.size() && i < mValues.size(); ++i ) {
if( mRadioButtons[i]->isChecked() ) {
txt = mValues[ i ];
break;
}
}
} else if( mProperties->appearance == Compact ) {
if( mListWidget->currentRow() < mValues.size() )
txt = mValues[ mListWidget->currentRow() ];
} else {
if( mComboBox->currentIndex() < mValues.size() )
txt = mValues[ mComboBox->currentIndex() ];
}
if ( s.isAttribute() ) {
context().setAttribute( s.name(), txt );
} else {
QDomElement e = ref().applyElement( context() );
if ( e.isNull() ) {
e = createElement( ref() );
}
QDomNode n = e.firstChild();
if( n.isNull() ) {
n = mManager->document().createElement( txt );
e.appendChild( n );
}
else {
if( n.isText() ) {
QDomText t = n.toText();
t.setData( txt );
} else if( n.isElement() ){
n.toElement().setTagName( txt );
}
}
}
}
示例5: addText
void KWDWriter::addText(const QDomElement ¶graph, const QString& _text, int format_id, bool keep_formatting)
{
QString text = _text;
QDomNode temp = paragraph.elementsByTagName("TEXT").item(0).firstChild();
QDomText currentText = temp.toText();
if (temp.isNull()) {
kDebug(30503) << "no text"; return;
}
QString oldtext = currentText.data();
int oldLength = oldtext.length();
if (keep_formatting) {
if (oldLength) {
++oldLength;
oldtext.append('\n');
}
} else {
if (oldLength)
++oldLength; // add new trailing space char
text = text.simplified(); // drop all unprintable chars
}
QString newtext;
if (keep_formatting)
newtext = oldtext + text;
else {
newtext = oldtext + ' ' + text;
newtext = newtext.simplified(); // strip possible new space at beginning.
}
currentText.setData(newtext);
int newLength = text.length();
QDomElement lastformat = currentFormat(paragraph, true);
if (lastformat.attribute("id").isEmpty()) // keep old id value, e.g. for LINK URL
lastformat.setAttribute("id", format_id);
lastformat.setAttribute("pos", QString("%1").arg(oldLength));
lastformat.setAttribute("len", QString("%1").arg(newLength));
}