Update
void MainWindow::readXml()
{
QDomDocument Champions;
QFile xmlFile("champions.xml");
xmlFile.open(QIODevice::ReadOnly);
Champions.setContent(&xmlFile);
QDomElement root = Champions.firstChildElement();
QDomNodeList ChampionNames = root.elementsByTagName("Champion");
for(int i = 0; i < ChampionNames.count(); i++)
{
QDomNode championNode = ChampionNames.at(i);
if(championNode.isElement())
{
QDomElement Champion = championNode.toElement();
ui->comboBox->addItem(Champion.attribute("Name"));
}}}
Managed to get something like this so I've the names in the comboBox now :)
I'm new to this community so I'm happy to meet all of You!
First I want to inform You that I'm pretty new to Qt programming however I've had some basic c++ lessons in school though it was only console programming and I've never worked on stuff like that. Why I've started with Qt? It looked easy to me and hell it was compared to visual studio! So here is my problem.
Basiclly I have a comboBox where I would read my "Name="" " attributes in. There will be around 100 maybe abit less maybe a bit more don't know Yet. I don't know how to start with everything this since I have never done such thing before. What i want the software to do is basiclly when i select a "name" in the combobox, i want all the attributes ("Q" "W" "E" "R") to be printed out in the 4 labels as You can see on the little image I've added.
I don't know if I need to first read the file into some strings arrays or data structures. Do I need to search the XML file for the "Name" which is selected in ComboBox and then somehow print it out? I spent some time on this but I cant find a way to achive the thing I want. I would really appriciate some code exemples specially using the ComboBox since as said I'm new to this.
XML File looks like this in case image is blurry:
<ROOT>
<Champ Name="XXX1">
<Q>QQ1</Q>
<W>WW1</W>
<E>EE1</E>
<R>RR1</R>
</Champ>
<Champ Name="XXX2">
<Q>QQ2</Q>
<W>WW2</W>
<E>EE2</E>
<R>RR2</R>
</Champ>
</ROOT>
I'm really bad on describing things so I've made a small ilustration using a pen to let You understand me better :)
Thanks for Your support in advance! Hope I'm clear enought with my question. Have a great day.