Hello anyone,

I have a QTreeWidget with a saveFile function.
I want to save 4 items in a text file with a tab between the items on a row.
This code save the items. 1 item on 1 row.
See code:
Qt Code:
  1. void MainWindow::saveFile(const QString &fileName)
  2. {
  3.  
  4. QFile file( fileName );
  5. if ( !file.open(QFile::WriteOnly))
  6. return;
  7.  
  8. QTextStream out( &file );
  9.  
  10. int ind = 0;
  11. while(QTreeWidgetItem *item = contactView->topLevelItem(ind)) {
  12. for ( unsigned int i = 0; i < 4; i++ )
  13. out << item->text(i) << "\n";
  14.  
  15. ind ++;
  16. }
  17. file.close();
  18.  
  19. }
To copy to clipboard, switch view to plain text mode 
Must i use QStringlist with join or can i change the code a litle bit.