1

I'm trying to convert the QTableView filled with QSQLTableModel data into CSV file. My current code is the following (actually similar to what was posted here already):

QFile f( "table.csv" );
if (f.open(QFile::WriteOnly | QFile::Truncate))
{
    QTextStream data( &f );
    QStringList strList;

    for( int r = 0; r < ui->table->model()->rowCount(); ++r )
    {
        strList.clear();
        for( int c = 0; c < ui->table->model()->columnCount(); ++c )
        {

            QVariant data = ui->table->model()->index( r, c ).data();
            strList << "\" "+data.toString()+"\" ";

        }
        data << strList.join( ";" )+"\n";
    }
    f.close();
}

This works perfectly, except that the locale is incorrect, i.e. points/commas in doubles, dates etc. The application locale is correct however, QTableView displays everything correctly.

Is there any way to set QLocale or to use it somehow when converting QVariant::toString ???

0 Answers0