PDA

View Full Version : Exporting Qtablewidget to CSV..Segmentation fault after some values



prabhudev
16th August 2012, 11:19
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()
{
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();
}

}

yeye_olive
16th August 2012, 13:04
Run a debugger.

prabhudev
21st August 2012, 10:15
issue resolved...
I set all rows to null before inserting the data in to qtablewidget...