Z
Z
Zaur Ashurbekov2015-08-18 10:58:07
Qt
Zaur Ashurbekov, 2015-08-18 10:58:07

Why is Cyrillic displayed incorrectly in the interface?

Hello Toaster!
The problem is that when adding Cyrillic to the interface using code, for example like this (in QComboBox):

ui->userList->addItem("Стандартный пользователь");
ui->userList->addItem(tr("Стандартный пользователь"));
ui->userList->addItem(trUtf8("Стандартный пользователь"));

in all three cases it displays black diamonds with questions. Latin is displayed normally.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2015-08-18
@zaurius

Because Qt expects unicode strings.
QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
ui->userList->addItem(codec->toUnicode("Standard User"));
Try this code, it should work.

T
TriKrista, 2015-08-18
@TriKrista

Do not do it this way:

ui->userList->addItem(tr("Стандартный пользователь"));
ui->userList->addItem(trUtf8("Стандартный пользователь"));

tr and trUtf8 are usually used to localize the application, write in English, then include "translation" and Qt will substitute everything.
Try adding items to the combobox in the form builder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question