View Full Version : Problem with QTableView, or QSqlTableModel, postgresql and locale

21st December 2009, 22:14
My locale is pl_PL.
I have problem with QTableView and postgresql database.
Double values is represented by integer.
I set names in postgres by: set names 'latin2'.
When i write some double 1.09 in QTableView i see as 1
but in psql is 1.09. How can i set type in model or tableview to float or double for some columns??

I overload in QSqlTableModel method:
QVariant QSqlTableModel::data(const QModelIndex & i, int role ) const
and show QVariant for special column. But i still get integer.

I forgot, my base table isn't table but perspective.

22nd December 2009, 04:57
This looks like a locale issue, if you set the QSqlQuery::setNumericalPrecisionPolicy to QSql::HighPrecision, does it give you the correct value? (Maybe with . instead of ,? or , instead of .?). I'm not sure how to fix the issue from there tho, maybe QLocale::setDefault?

22nd December 2009, 08:09
In pl_PL locale decimal separator is , not .

22nd December 2009, 13:18
ok, but this method is in qt4.6 ;-/ (i have 4.5.3 in arch linux, and i don't want recompile qt)
i know

How to set in qlocale decimalPoint??

22nd December 2009, 15:39
On Qt-4.6.0 from default settings works fine;-)

23rd December 2009, 02:53
On Qt-4.6.0 from default settings works fine;-)

Heh, could be something I fixed in between 4.5.3 and 4.6. There's been a lot of bugfixing work done, starting from 4.5.0

Re the setPrecisionPolicy, that should be there in the result from a long time ago, 4.6 only surfaced it to the database as well as the query (and takes the default from the db setting).

That said, it's good to see it's working for you :)