PDA

View Full Version : Convert Html content into QStandardItemModel



nikhilqt
28th February 2012, 20:24
Hi,

Is there any class where I can directly match the xml contents into QStandardItemModel ? Or do i need to do it by QDomDocument? Thanks for your help.

wysota
28th February 2012, 21:22
Why do you want to convert one model to another one? Isn't it better to write a model that will operate directly on the xml structure?

nikhilqt
28th February 2012, 21:48
Actually I need to parse the webpage, extract table, and need to do processing on the contents of it. May be display it as tablemodel, treemodel.

Now, I am following the straight forward approach of loading the html page using QDomDocument and trying to parse using node, elements. I am trying figure out is there any more elegant way of doing this.

wysota
28th February 2012, 23:12
So what good would it bring to have a model?

nikhilqt
29th February 2012, 20:16
So what good would it bring to have a model?

So, I can directly set a model for the tableview, Instead of adding item by item. Right ?

wysota
29th February 2012, 20:46
Yes, that's true. But you don't have to copy the data anywhere. If you have the data somewhere (like in the xml document) just wrap the data in the QAbstractItemModel interface. If you're only after showing the data then Qt comes with an example that creates a read-only model around QDomDocument.