Qt 中 QXml/QDom*** api设计吐槽
昨天下午搞了一下Qt中的dom解析。發(fā)現(xiàn)并沒(méi)有java中的好用。
1. 除了QDomDocument類(lèi)以外,均沒(méi)有toString方法。我僅僅想吧QDom**->QString 只能通過(guò)QDomDocuemnt來(lái)實(shí)現(xiàn)
2. 就算用QDomDocument。 需要將QDom** append到QDomDocument。就會(huì)出現(xiàn)下面的結(jié)果:
QDom**是通過(guò)此QDomDocument::create**出來(lái)的。可以append.
QDom**不是通過(guò)此QDomDocument::create**出來(lái)的,QDomDocument用帶參的初始化方法初始化的。可以append
QDom**不是通過(guò)此QDomDocument::create**出來(lái)的,QDomDocument用無(wú)參的初始化方法初始化的。不可以append
3. QDomNode是所有QDom**的父類(lèi)。其中appendChild()又是我們經(jīng)常用的。看官網(wǎng)注釋
Appends newChild as the node's last child.If newChild is the child of another node, it is reparented to this node. If newChild is a child of this node, then its position in the list of children is changed.If newChild is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and appended.If newChild is a QDomElement and this node is a QDomDocument that already has an element node as a child, newChild is not added as a child and a null node is returned.Returns a new reference to newChild on success or a null node on failure.Calling this function on a null node(created, for example, with the default constructor) does nothing and returns a null node.The DOM specification disallow inserting attribute nodes, but for historical reasons, QDom accepts them anyway.1. 如果newChild是其他節(jié)點(diǎn)的孩子,那么重定向到此節(jié)點(diǎn),如果是這個(gè)節(jié)點(diǎn)的孩子,則改變位置。
如果我僅僅想復(fù)制newChild到其他節(jié)點(diǎn)。那么我需要copy newChild,比較蛋疼需要重新new一個(gè)然后一個(gè)一個(gè)copy。
ok 我知道寫(xiě)個(gè)clone方法或者有api可以調(diào)用。但是增加一個(gè)直接插入的函數(shù)難道不好么?我?guī)推饌€(gè)名字:appendChildFocus();
? ? ?2. 3. 就不說(shuō)了。也是限制條件。?
?
?我只關(guān)注了這些。浪費(fèi)了我4個(gè)小時(shí)的時(shí)間后,然后決定用QJson OYE.?
?google了一下大家怎么評(píng)論的。第一條就是" just confusing me!!!" ?所以建議大家能不用QDom就不用。
?
轉(zhuǎn)載于:https://www.cnblogs.com/blog-wenfeng/p/3334609.html
總結(jié)
以上是生活随笔為你收集整理的Qt 中 QXml/QDom*** api设计吐槽的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux设备模型(总结)
- 下一篇: 判断是否遵守某个协议