Shawn
28th August 2007, 08:20
I have parsed an XML file and got this,
class Element
{
public:
Element(const QString &type)
:ElementType(type)
{
content.clear();
}
~Element(void) {}
void addContent(const QString str);
void addSubElement(Element* element);
void addAttr(const QString attr, const QString value);
void toText(QTextStream &os, int level); //print for testing
private:
QString ElementType, content;
QList<Element*> list_subElement;
QMap<QString, QString> map_attr;
};
ElementType represents the name of the tag, content represents the value of this tag,
every element also has many attribute-value pair, which are represented by the QMap,
the child element is represented by the QList<Element*>
For this simple XML file:
<Class No.="02">
<Student No.="0215">Mike Jasen</Student>
</Class>
My Problem is:
I want to show the Element and child elements in a tree-view. If any element is clicked in this tree-view, the attribute-value pairs can be shown in the table-view. How can I implement this?
This pic is want I want, I draw it using photofiltre
class Element
{
public:
Element(const QString &type)
:ElementType(type)
{
content.clear();
}
~Element(void) {}
void addContent(const QString str);
void addSubElement(Element* element);
void addAttr(const QString attr, const QString value);
void toText(QTextStream &os, int level); //print for testing
private:
QString ElementType, content;
QList<Element*> list_subElement;
QMap<QString, QString> map_attr;
};
ElementType represents the name of the tag, content represents the value of this tag,
every element also has many attribute-value pair, which are represented by the QMap,
the child element is represented by the QList<Element*>
For this simple XML file:
<Class No.="02">
<Student No.="0215">Mike Jasen</Student>
</Class>
My Problem is:
I want to show the Element and child elements in a tree-view. If any element is clicked in this tree-view, the attribute-value pairs can be shown in the table-view. How can I implement this?
This pic is want I want, I draw it using photofiltre