Fooling around with the treemodel, I hoped this would work. I want to wrte the contents of the treemodel in the simpletreemodel example to a text file. I thought the index function would get the correct data from the child items if the column counter > 0, so that the contents of the children are simply accessible with model.data(i,j). All I get is a list of contents of the parent items (so at index i,0) , I cannot acces the content of the children.
Qt Code:
  1. QFile fout("some.txt");
  2. fout.open(QIODevice::ReadWrite);
  3. for (int i = 0; i < model.rowCount(); i++)
  4. {
  5. QString S = "";
  6. for (int j = 0; j < model.columnCount(); j++)
  7. {
  8. QVariant d = model.data(model.index(i,j),0);
  9. S = S + d.toString()+";";
  10. }
  11. S = S + "\n";
  12. QByteArray line(S.toAscii());
  13. fout.write(line);
  14. }
  15. fout.close();
To copy to clipboard, switch view to plain text mode 
my reasoning is not correct obviously, but I don't get it. Thanks