Well, apparently item->node().toElement() which returns a QDomElement has the necessary "set" functions and it works. So I think I've found a way to fully modify my XML DOM file through QTreeView.
This does the trick for me:
switch (index.column()){
case 0: // added - works
item->node().toElement().setTagName(value.toString());
break;
case 1: // added - works
// this shall be modified to account for nonstandard spacings, etc.
aux = value.toString().trimmed();
aux.remove("\"");
attributes.clear();
attributes = aux.split(" ");
for(int i = 0; i<attributes.size(); i++){
item->node().toElement().setAttribute(attributes.at(i).split("=").at(0),
attributes.at(i).split("=").at(1));
}
break;
case 2: // Left it as it is
item->node().setNodeValue(value.toString()); // This works - QTreeView is updated
break;
}
switch (index.column()){
case 0: // added - works
item->node().toElement().setTagName(value.toString());
break;
case 1: // added - works
// this shall be modified to account for nonstandard spacings, etc.
aux = value.toString().trimmed();
aux.remove("\"");
attributes.clear();
attributes = aux.split(" ");
for(int i = 0; i<attributes.size(); i++){
item->node().toElement().setAttribute(attributes.at(i).split("=").at(0),
attributes.at(i).split("=").at(1));
}
break;
case 2: // Left it as it is
item->node().setNodeValue(value.toString()); // This works - QTreeView is updated
break;
}
To copy to clipboard, switch view to plain text mode
Bookmarks