Hi. I have a qtabewidget which has 10 rows and 2000 columns. When I save it to CSV after saving some rows(around 1500) its saying segmentation fault...Whats wrong with the code...
Qt Code:
  1. void Read_Table::on_to_CSV_clicked()
  2. {
  3. QFile f( "save1.csv" );
  4.  
  5. if (f.open(QFile::WriteOnly))
  6. {
  7. QTextStream data( &f );
  8. QStringList strList;
  9. strList.clear();
  10.  
  11. for( int c = 0; c < ui->O_Table->columnCount(); ++c )
  12. {
  13. // strList << "\" "+ui->O_Table->item( r, c )->text()+"\" ";
  14. strList <<
  15. "\" " +
  16. ui->O_Table->horizontalHeaderItem(c)->data(Qt::DisplayRole).toString() +
  17. "\" ";
  18.  
  19.  
  20. }
  21. data << strList.join( ";" )+"\n";
  22. for( int r = 0; r < ui->O_Table->rowCount(); ++r )
  23. {
  24. strList.clear();
  25. for( int c = 0; c < ui->O_Table->columnCount(); ++c )
  26. {
  27. strList << "\" "+ui->O_Table->item( r, c )->text()+"\" ";
  28.  
  29.  
  30. }
  31. data << strList.join( ";" )+"\n";
  32. }
  33. f.close();
  34. }
  35.  
  36. }
To copy to clipboard, switch view to plain text mode