Questions tagged [qlocale]

QLocale is a class from the Qt Toolkit which converts between numbers and their string representations in various languages.

Documentation can be found here (Qt4) and here (Qt5).

21 questions
3
votes
4 answers

QLocale detects system language incorrectly on Windows with language pack installed

I am attempting to detect current system language with QLocale: QLocale::Language sysLangId = QLocale::system().language(); However, it's not working correctly. I'm on Russian Windows 7 with English language pack applied, but language() returns…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
2
votes
0 answers

Why does QDialogButtonBox labels' language change between design and execution?

I use a french version of QtCreator v4.11.1 When I create a default QDialogButtonBox using the form designer (or using Qt Designer), the buttons are labelled in french language. Both buttons have 'OK' and 'Annuler' labels as seen below. However,…
Pat. ANDRIA
  • 2,330
  • 1
  • 13
  • 27
2
votes
1 answer

How to display a QDate-month with a different locale than system?

The function QDate::toString(const QString &format) allows to display the month name with MMM (e.g. 'Jan' to 'Dec') or MMMM (e.g. 'January' to 'December'). But this function uses the system locale from QLocale::system() (source code). What is the…
ymoreau
  • 3,402
  • 1
  • 22
  • 60
2
votes
1 answer

Qt Why use QString::number() over QLocale().toString()?

The application I am working on will be launched in many countries and needs to support their language. I've been going back through my code and replacing every instance of: QString::number() and QString().toDouble() with QLocale().toString() and…
picklechips
  • 746
  • 2
  • 8
  • 28
2
votes
1 answer

Converting number to currency string using QLocale class

I am trying to convert numbers into currency string. I am using QLocale::toCurrencyString() method. When I set my system locale(changed via Windows 7 Region and Language setup) as India and try to convert a number say 1872345.00 using…
Programmer
  • 1,290
  • 2
  • 12
  • 16
1
vote
1 answer

QLocale codeToTerritory only worls with 2-digit codes

I would like to get the Country name for any ISO 3166 country codes. My project currently uses 3-digit codes, so if possible, from that. According to the Qt documentation QLocale::countryToTerritory should solve this, but in my test programs, it…
Hajdu Gábor
  • 329
  • 1
  • 12
1
vote
1 answer

How do I get the "long" name of a language from a QLocale?

I have created a QComboBox to list various languages supported in a Qt Application. In order to populate the items in the combo box, I search through all the .qm files for available language codes. QDir dir(TRANSLATION_PATH); QStringList file_names…
Ben Jones
  • 652
  • 6
  • 21
1
vote
1 answer

QLocale and QSettings

Premise: I'm on osx using qt5.7 I've changed the decimal separator in the System Preferences - Language and Region - Advanced to use the comma: I have a problem in storing/restoring the QLocale value via QSettings. This is the main.cpp: #include…
bibi
  • 3,671
  • 5
  • 34
  • 50
1
vote
1 answer

How to convert a string with comma to float in QT?

in my csv file values decimalpoint is a comma. So I can open the csv in Excel and Excel won't format my values to date. When I open the file in my own software and convert the String to float, the values can't be read: bool ok returns false.…
Cat
  • 11
  • 1
  • 2
1
vote
0 answers

Qt get language name in its native form

I'm adding language support into a Qt C++ application currently using QLocale and QTranslator. When the user selects the language from the settings menu, I want to show them the Language name in the native form (e.g. Deutsch instead of German), but…
SionHughes
  • 128
  • 11
1
vote
0 answers

How to differentiate between traditional and simplified Chinese using QLocale

I have to show the list of languages available for user to select. The list will have (Auto) as the first option which is the operating system language and will have further languages as add-on. Here English is the Auto Language. The problem here…
Bharathi
  • 337
  • 1
  • 5
  • 17
1
vote
2 answers

QLocale toDate always return invalid QDate on "es" locale

Why this code return an invalid date? QLocale locale("es"); QDate date = locale.toDate("1-Jun-14", "d-MMM-yy"); If debug the locale variable, it is initialized correctly to locale es_ES, but doesn't return the date and date.isValid() returns false.
mabg
  • 1,894
  • 21
  • 28
1
vote
1 answer

QLocale - Validate price

I'm having trouble validating price. Example accepted price: 10,00 / 100,00 / 1.000,00 Not accepted: 10 / 100 / 1000.00 Code, but this passing 100 / 10 / 1000.00 bool ok; QLocale::setDefault(QLocale(QLocale::Portuguese, QLocale::Brazil)); QLocale…
user628298
  • 287
  • 2
  • 14
0
votes
0 answers

QInputDialog QLocale

A customer of Latvia inputs text in QInputDialog using apostrophe as escape, which he claims is the common method for inputting text there. So apostrophe, followed by "a" should give "ā". According to him, it works in all system dialogs, but not in…
charlie
  • 68
  • 2
  • 8
0
votes
0 answers

How to define Turkish character to QStringList on QT

I want to define QString Turkish Character on Qt. I define below: QString aa="çİĞ"; I want to see aa qDebug()<
Mahmut
  • 7
  • 4
1
2