ive managed to do the following:
//where "repoList" is my treeWidget
QFile repositories
("/tmp/repositories");
repositories.
open(QFile::WriteOnly |
QFile::Truncate);
int count =
parent ? parent->childCount() : repoList->topLevelItemCount();
for (int i = 0; i < count; i++)
{
parent ? parent->child(i) : repoList->topLevelItem(i);
// do something with the item
repositoryList << repoList->topLevelItem(i)->text(0);
}
repositories.close();
//where "repoList" is my treeWidget
QFile repositories("/tmp/repositories");
repositories.open(QFile::WriteOnly | QFile::Truncate);
QTextStream repositoryList(&repositories);
QTreeWidgetItem *parent;
int count =
parent ? parent->childCount() : repoList->topLevelItemCount();
for (int i = 0; i < count; i++)
{
QTreeWidgetItem *item =
parent ? parent->child(i) : repoList->topLevelItem(i);
// do something with the item
repositoryList << repoList->topLevelItem(i)->text(0);
}
repositories.close();
To copy to clipboard, switch view to plain text mode
I found the above code in an old thread of qt-interest
The thing is, that even if the above code works nicely, saves my items in one line.
for example, my items in the QTreeWidget is like this:
test repo1
test repo2
test repo3
test repo1
test repo2
test repo3
To copy to clipboard, switch view to plain text mode
The above code saves it like this:
test repo 1test repo 2test repo 3
test repo 1test repo 2test repo 3
To copy to clipboard, switch view to plain text mode
Ive tried to customize the code but no work...
any suggestions?
Bookmarks