Results 1 to 6 of 6

Thread: Problem with QTableView, or QSqlTableModel, postgresql and locale

  1. #1
    Join Date
    Oct 2008
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with QTableView, or QSqlTableModel, postgresql and locale

    Hi!
    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.
    Last edited by zygmunt; 21st December 2009 at 21:21.

  2. #2
    Join Date
    Dec 2009
    Location
    Brisbane
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QTableView, or QSqlTableModel, postgresql and locale

    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?

  3. The following user says thank you to tangential for this useful post:

    zygmunt (22nd December 2009)

  4. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QTableView, or QSqlTableModel, postgresql and locale

    In pl_PL locale decimal separator is , not .

  5. #4
    Join Date
    Oct 2008
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QTableView, or QSqlTableModel, postgresql and locale

    @tangential
    ok, but this method is in qt4.6 ;-/ (i have 4.5.3 in arch linux, and i don't want recompile qt)
    @lesiok
    i know

    How to set in qlocale decimalPoint??

  6. #5
    Join Date
    Oct 2008
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QTableView, or QSqlTableModel, postgresql and locale

    On Qt-4.6.0 from default settings works fine;-)
    Thanks.

  7. #6
    Join Date
    Dec 2009
    Location
    Brisbane
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QTableView, or QSqlTableModel, postgresql and locale

    Quote Originally Posted by zygmunt View Post
    On Qt-4.6.0 from default settings works fine;-)
    Thanks.
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.