Added after 5 minutes:
Thank you but I still have the problem. The explaination is as follows.
I have a string and I have to write it to my database:
QString aField;
// e.g. there is a text "абвгд"
QString aField; // e.g. there is a text "абвгд"
To copy to clipboard, switch view to plain text mode
I use QSqlQuery:
query.bindValue(":aField", aField.toUtf8());
query.bindValue(":aField", aField.toUtf8());
To copy to clipboard, switch view to plain text mode
Then in another C++ file I try to get this string from the database with QByteArray:
QByteArray aField_ = q.value(0).toByteArray();
To copy to clipboard, switch view to plain text mode
Then I make a codec:
QTextCodec* aCodec = QTextCodec::codecForName("UTF-8");
To copy to clipboard, switch view to plain text mode
Here I convert QByteArray to QString:
QString aField
= aCodec
->toUnicode
(aField_
);
QString aField = aCodec->toUnicode(aField_);
To copy to clipboard, switch view to plain text mode
Now I put the string to the cell of QTableWidget:
ui.tableWidget->setItem(rowNumber, 1, item);
item = new QTableWidgetItem(aField);
ui.tableWidget->setItem(rowNumber, 1, item);
To copy to clipboard, switch view to plain text mode
Latin characters are displayed okay but cyrrilic are like strange symbols.
What I did wrong?
Bookmarks