Results 1 to 9 of 9

Thread: Import PostgreSQL Values to QT

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Import PostgreSQL Values to QT

    Hello everybody,

    I have a PostreSQL Database. I am able to import values to a listView for example.
    My problem is:
    I have in a table a value like this: "lächerlich" .
    I get in my listview l[]cherlich

    How could i get the exactly value on qt?

    Qt Code:
    1. QSqlQuery select("select language1, plural, language2, description from words_tbl order by language1");
    2. while(select.next())
    3. {
    4. QString language1 = select.value(0).toString();
    5. ...
    To copy to clipboard, switch view to plain text mode 


    Thanks
    Last edited by raphaelf; 16th May 2007 at 14:20.
    Think DigitalGasoline

  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: Import PostgreSQL Values to QT

    You have to use a proper text codec either in the database or in your app (or both).

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

    raphaelf (23rd May 2007)

  4. #3
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Import PostgreSQL Values to QT

    Hallo Wysota,

    Under Postre i am using text datatype and on qt QString..

    Where could i found a example for my problem?
    I dont have understand exactly how to implement this..
    Think DigitalGasoline

  5. #4
    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: Import PostgreSQL Values to QT

    www.postgresql.org probably... You have to be aware which encoding the database uses and use the same to fetch data into QString.

  6. The following user says thank you to wysota for this useful post:

    raphaelf (23rd May 2007)

  7. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Import PostgreSQL Values to QT

    Qt talks to the PostgreSQL in Unicode, so it should work out of the box. How did you fill the database with data?

  8. The following user says thank you to jacek for this useful post:

    raphaelf (23rd May 2007)

  9. #6
    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: Import PostgreSQL Values to QT

    Quote Originally Posted by jacek View Post
    Qt talks to the PostgreSQL in Unicode, so it should work out of the box.
    Unless the database doesn't contain data in Unicode (or at least in the encoding specified by the database).

  10. The following user says thank you to wysota for this useful post:

    raphaelf (23rd May 2007)

  11. #7
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Import PostgreSQL Values to QT

    Hi everybody,

    If i write a value direct on PGAdmin i can see extrange values on QT, but if i fill the database on QT it works fine..

    My idea is to fill data from qt, so thats ok..

    Thank you all
    Think DigitalGasoline

  12. #8
    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: Import PostgreSQL Values to QT

    It probably means the database contents uses a different encoding than declared in the database.

  13. #9
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Import PostgreSQL Values to QT

    Try check client_encoding in postgresql.conf
    a life without programming is like an empty bottle

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.