Displaying Japanese characters in Qt
-
Dear all,
I am trying to display Japanse characters on my display using QPainter. I followed the below approaches
1, Set the QFont to "japanse", set font size to 24 and font set as bold, (pasted the code snippet below) I expected the output to be displayed in white colour with a blue outline and with the above mentioned font parameters, but the text was displayed in blue colour with a lesser font size and was not bold.
2, I tried as per mentioned in the post http://qt-project.org/forums/viewthread/32704 but I am getting junk characters in the display.
Regards,
Jis
@
QPainter * painter1;
QFont m_textFont;
QPen m_bluepen;
QBrush m_whiteBrush;
this->m_textFont.setPointSize(24); //increased text font size from 21 to 23 for error messages and date and time
this->m_textFont.setBold(true);
this->m_textFont.setFamily("japanese");
whitepath.addText(20,400,this->m_textFont,QString::fromUtf8("警察は、バックステー"));
whitepath.addText(20,400,this->m_textFont,obj_verbalWarning.message_id);
painter1->setPen(this->m_bluepen);
painter1->setBrush(this->m_whiteBrush);
painter1->drawPath(whitepath);
@[edit: Added missing coding tags @ SGaist]
-
Hi, and welcome to the Qt Dev Net!
[quote]
@
QString::fromUtf8("警察は、バックステー");
@
[/quote]This requires your .cpp file to be encoded in UTF-8. Have you checked that you have saved it in UTF-8, and not SHIFT-JIS or something else?Also, what OS and compiler are you using?