Results 1 to 4 of 4

Thread: QTableView and precsions

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableView and precsions

    I use QSqlQueryModel and QTableView in my application to browse data in a database. My database stores some number with decimals points in it. I want my view to just show me just 2 digit after the decimal point. this must be doable is it not? and if so what is the easiest way to do this.

    baray98

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView and precsions

    You can either ask the database to trim the numbers using a proper sql function or you can do the trimming after you receive the values using, for instance, QString::number() where you can pass the precision you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView and precsions

    I am not sure how can i trim using SQL statement ( newbie ) , if you can tell me how please do ..

    One thing i could do it inherit QSqlTableModel then trim it right there..is this what you meant by using QString::number()?


    baray98

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTableView and precsions

    That isn't meant cruel, but you should be able to read docs and find such easy informations! Especially if the doc are very well organized like the MySQL one:

    MySQL 6.0 Reference Manual :: 11 Functions and Operators :: 11.5 Numeric Functions

    There is a nice function called: ROUND(X,D)

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.