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...
void Read_Table::on_to_CSV_clicked()
{
if (f.
open(QFile::WriteOnly)) {
strList.clear();
for( int c = 0; c < ui->O_Table->columnCount(); ++c )
{
// strList << "\" "+ui->O_Table->item( r, c )->text()+"\" ";
strList <<
"\" " +
ui->O_Table->horizontalHeaderItem(c)->data(Qt::DisplayRole).toString() +
"\" ";
}
data << strList.join( ";" )+"\n";
for( int r = 0; r < ui->O_Table->rowCount(); ++r )
{
strList.clear();
for( int c = 0; c < ui->O_Table->columnCount(); ++c )
{
strList << "\" "+ui->O_Table->item( r, c )->text()+"\" ";
}
data << strList.join( ";" )+"\n";
}
f.close();
}
}
void Read_Table::on_to_CSV_clicked()
{
QFile f( "save1.csv" );
if (f.open(QFile::WriteOnly))
{
QTextStream data( &f );
QStringList strList;
strList.clear();
for( int c = 0; c < ui->O_Table->columnCount(); ++c )
{
// strList << "\" "+ui->O_Table->item( r, c )->text()+"\" ";
strList <<
"\" " +
ui->O_Table->horizontalHeaderItem(c)->data(Qt::DisplayRole).toString() +
"\" ";
}
data << strList.join( ";" )+"\n";
for( int r = 0; r < ui->O_Table->rowCount(); ++r )
{
strList.clear();
for( int c = 0; c < ui->O_Table->columnCount(); ++c )
{
strList << "\" "+ui->O_Table->item( r, c )->text()+"\" ";
}
data << strList.join( ";" )+"\n";
}
f.close();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks