Results 1 to 3 of 3

Thread: translate database column names

  1. #1
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default translate database column names

    How would you translate table name and field name from database?
    for example i would like to have QSqlTableModel with QTabelView but column names in view translatable
    is there a proper way with tr(), or some hack/trick that someone knows?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: translate database column names

    You can set the headers that the QSqlTableModel serves up using QSqlTableModel::setHeaderData(). Views will generally display these unaltered. See the first example in the QSqlTableModel docs.

  3. #3
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: translate database column names

    OK, thanks, somehow i missed that
    that works if i know the table name, what if i have generic form where user selects table name, form for direct database editing, i dont know filed names yet, where do i intervene
    also, if i have some text data from database, that should be translated also,
    for example table `item_type` that is fk on table `item` and i have QComboBox where i select type and user sees strings loaded from database, how do i translate those strings
    somehow tr() seams insufficient, or i am missing something, and there is a way to add more dynamic translations with tr
    Or i shoud create my own tr(), and maintain all translations table in database, without .ts and .qm files

    EDIT

    For those with similar problems there is a great document on
    http://doc.qt.digia.com/qq/qq03-swedish-chef.html
    and since the link can change the document is titled
    Forgot a tr()?
    by Jasmin Blanchette

    so you can google it

    I can subclass QTranslator to search for messages in database, use fake c++ code....
    Last edited by davidovv; 30th January 2014 at 09:41.

Similar Threads

  1. Replies: 0
    Last Post: 1st June 2013, 22:14
  2. list tables column name (database)
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2012, 11:18
  3. SQL Query column names
    By rakkar in forum Newbie
    Replies: 1
    Last Post: 9th September 2009, 19:06
  4. Replies: 5
    Last Post: 13th November 2008, 13:43
  5. MySQL column names extraction
    By MarkoSan in forum Qt Programming
    Replies: 2
    Last Post: 12th October 2007, 11:51

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.