QDom coloring

  • Hi i'm handling somme xml files with QDom and i want to color some of the QDomNode on some conditions but i didn't find any thing about the color in QDom or in QDomNode.


  • XML nodes (QDomNode) do not have a color.

  • Is there a work around to make them look like they are colored or event highlight?

  • As I understand you want to visualize an xml tree for which purpose you should use a QTreeView or QTreeWidget class (or similar). With these your question is reasonable. QDom is a data structure to store XML data therefore with those speaking about coloring is not understandable.

  • Yeah your right sorry i didn't explain myself properly i'm using QAbstractItemModel for the model and a custom class for the items. And i want to compare some filds in every lines of a xml files and color the ones which the comparaison return different.

  • So if you have a custom class for the items, store the color in the custom class and return it from the data() method of your model. The background color is queried by role==Qt::BackgroundRole

  • Thanks Gerolf, my problem now is how to get the item knowing only the QDomNode? cause when comparing i'm working with the qDomNodes.

  • I don't know the internas of your program, but at some time, you create your items. and there must be some logic on how to build them. And with the same logic, it should be possible to find them.

    That is something, you have to solve and that is not a Qt problem, more a logical one.

Log in to reply