[Interest] Display XML in tree view
Murphy, Sean
smurphy at walbro.com
Wed Aug 3 17:53:33 CEST 2016
> That's all right. I wasn't sure if you wanted to display "widget" or something
> else. Something you write previously made me think that might not be what
> you wanted.
Basically I want to just show the raw XML file, in its entirety, but allowing the
user to expand/collapse the XML nodes.
If you look at this sample XML page, http://www.w3schools.com/xml/simple.xml,
using Google Chrome (not sure if other browsers automatically do this, but a quick
test shows Chrome and Internet Explorer both do), the browser is displaying the XML
file exactly like what I'm trying to do inside a QTreeView: each XML tag that spans
multiple lines between its starting and closing tags has an expander button next to
it, allowing the user to hide sections of the document that they don't care about
seeing at that moment.
For bonus points, I'd love to modify the text colors for syntax highlighting tag
names vs. attribute names vs. attribute values, etc. I don't know if how easy it
is to have multiple colors in a single QModelIndex? A quick search says I might
need to use a delegate for that.
But leaving syntax highlighting aside for a second, my main goal is the just
expand/collapse behavior.
Sean
More information about the Interest
mailing list