I have two columns in treewidget viz. Files and path. Now I want to dump the items into an xml file. But the issue I'm facing is that I'm unable to extract the items.
QDomDocument document;
QDomElement root = document.createElement("Playlist");
document.appendChild(root);
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Save", "Do you want to save the playlist?", MessageBox::Yes | QMessageBox::No);
if(reply == QMessageBox::Yes)
{
//Add some elements
QDomElement playlist = document.createElement("MyPlaylist");
playlist.setAttribute("Name", "Playlist1");
root.appendChild(playlist);
for(int h = 0; h < ui->treeWidget->topLevelItemCount(); h++)
{
QDomElement file = document.createElement("File");
file.setAttribute("ID", ui->treeWidget->columnAt(0)); //1
file.setAttribute("Path", ui->treeWidget->columnAt(1)); //2
playlist.appendChild(file);
}
}
Can anyone help me out how to handle such situation wherein multiple column items are to be read. Comments 1 & 2 are the essence of whole story.