Results 1 to 3 of 3

Thread: how to make translatable items in QComboBox?

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default how to make translatable items in QComboBox?

    Hi,

    As the thread title suggests, I need to make the items translatable in QComboBox. I read item values using Windows API like;

    Qt Code:
    1. _ui.comboBoxPlayback->addItem(deviceName, i);
    To copy to clipboard, switch view to plain text mode 

    The device name here read directly from Windows.

    Any ideas?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to make translatable items in QComboBox?

    You can translate only "contsant" strings.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to make translatable items in QComboBox?

    Can the list of possible values for deviceName be determined at compile time?

    If yes, then you can provide your own translations using Qt's i18n/l10n support: just put all the strings wrapped with e.g. QT_TR_NOOP in your source file. The strings will be picked up by lupdate and you can provide translations for them. You can then modify your line to use a translation of the string, e.g. _ui.comboBoxPlayback->addItem(tr(deviceName), i).

    If not, then surely Qt cannot help you come up with translations at runtime. The Windows API may offer a way to obtain localized device names.

Similar Threads

  1. Qt Designer How to mark a string in Qt Desginer (e.g. a QLabel) as not translatable
    By sebastian.zenker in forum Qt Tools
    Replies: 1
    Last Post: 12th August 2010, 22:42
  2. QComboBox not showing all items
    By musikit in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2008, 16:01
  3. Occurance of Duplicate items in QComboBox
    By merry in forum Qt Programming
    Replies: 8
    Last Post: 12th September 2007, 15:05
  4. Automatically add items to a QComboBox (Qt4)
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 19th May 2006, 15:32
  5. QcomboBox items
    By therealjag in forum Newbie
    Replies: 5
    Last Post: 27th March 2006, 08:21

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.