Results 1 to 2 of 2

Thread: messed up umlauts when reading from PostgreSQL

  1. #1
    Join Date
    Feb 2010
    Posts
    18
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default messed up umlauts when reading from PostgreSQL

    Hi there,

    I'm trying to connect to a Postgres database and read some rows with QSqlQueryModel
    When I open the standard connection with

    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    QSqlQueryModel m;
    m.setQuery("select task_id, name, project_id, recurrence from task");

    everything works fine.

    Now when I open the connection with an alternative connection name

    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL", QLatin1String("Main"));
    QSqlQueryModel m;
    m.setQuery("select task_id, name, project_id, recurrence from task", QSqlDatabase::database(QLatin1String("Main")));

    the data in field name is not shown correctly. All german umlauts are not correct.

    Why is the encoding for the standard connection different from an alternative connection? How can I set the correct encoding?

    Thanks in advance
    Andreas

  2. #2
    Join Date
    Feb 2010
    Posts
    18
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: messed up umlauts when reading from PostgreSQL

    I found out, that using alternative connection works pretty good, when a default connection exists. So my suggestion is to always open the default connection and then open connections with other names.

    Still there is the question, what is the difference between calling addDatabase with and without the second parameter and why does it behave different?

Similar Threads

  1. QString::toLatin1() with umlauts
    By dape in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2010, 17:36
  2. Widgets look messed up
    By lechoo in forum Newbie
    Replies: 0
    Last Post: 1st October 2010, 08:24
  3. Replies: 1
    Last Post: 24th July 2008, 18:20
  4. Layout messed up
    By larry104 in forum Qt Tools
    Replies: 6
    Last Post: 8th August 2007, 23:09
  5. Custom Plug-in shows but layout is messed up
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 21st July 2007, 16:12

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.