日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Qt 中 QXml/QDom*** api设计吐槽

發(fā)布時(shí)間:2023/12/19 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Qt 中 QXml/QDom*** api设计吐槽 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

昨天下午搞了一下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)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。