ok, I am thinking about this as a table, every parent has a different nr children, and each child has several strings in my case (a data input structure for some software I am making). This works better :
for (int i = 0; i < model.rowCount(); i++)
{
QVariant d
= model.
data(model.
index(i,
0),
0);
// parent
for (int j = 0; j < model.rowCount(indexParent); j++)
{
for (int k = 0; k < model.columnCount(indexParent); k++)
{
d = model.data(model.index(j, k, indexParent),0);
S = S + d.toString()+";";
}
S = S + "\n";
}
fout.write(line);
}
fout.close();
QFile fout("hup.txt");
fout.open(QIODevice::ReadWrite);
for (int i = 0; i < model.rowCount(); i++)
{
QVariant d = model.data(model.index(i,0),0); // parent
QString S = "["+QString::number(i)+"-" + QString::number(0) + "] " + d.toString()+";\n";
QModelIndex indexParent = model.index(i, 0);
for (int j = 0; j < model.rowCount(indexParent); j++)
{
S = S + "["+QString::number(i)+"-" + QString::number(j) + "] ";
for (int k = 0; k < model.columnCount(indexParent); k++)
{
d = model.data(model.index(j, k, indexParent),0);
S = S + d.toString()+";";
}
S = S + "\n";
}
QByteArray line(S.toAscii());
fout.write(line);
}
fout.close();
To copy to clipboard, switch view to plain text mode
Bookmarks