QPainter drawText with different language
Hello,
How can I use QPainter to draw string that is not English origin?
I have a QLineEdit that accept external input from user, and then draw it using QPainter:
QPainter->drawText( QPoint( 0, 0 ), QLineEdit->text() );
If user inputs English, Spanish, German, etc, the draw is fine.
However, when user type Chinese, Japanese, or Korean that are not English origin, the QPainter doesn't draw anything...
How can I fix the problem?
Thank you for help.
Re: QPainter drawText with different language
Does the used font for your painter support the Chinese/etc. fonts?
(And is the given point not the bottom left of the base line of the characters? maybe the text is drawn outside your display area.)
Re: QPainter drawText with different language
Quote:
Originally Posted by
Lykurg
Does the used font for your painter support the Chinese/etc. fonts?
(And is the given point not the bottom left of the base line of the characters? maybe the text is drawn outside your display area.)
The QPainter draws correctly if I do QPainter->drawText( QPointF, QObject::tr( "text" ) ), where text translation can be found in the *.qm file
However, it doesn't draw with QPainter->drawText( QPointF, text ), where text is already a string of Chinese character. My Linux system has the used font installed....
Re: QPainter drawText with different language
It becomes interesting.
I did QObject::tr( text ), and if text is already a Chinese character, it didn't work. I remove QObject::tr and it works.
The problem is if the text is an English string and I want to translate to Chinese, it will not do the translation because QObject::tr is removed...
How can I take care bother cases?
Thanks
Re: QPainter drawText with different language
Quote:
Originally Posted by
lni
I did QObject::tr( text ), and if text is already a Chinese character, it didn't work. I remove QObject::tr and it works.
But that means that something with your translation file is not correct, because tr() returns the same string if no translation is found. What does a qWarning() << QObject::tr( text );? If it displays "" then your problem is in that (=translation file/system) not in the painter.
Quote:
How can I take care bother cases?
Before that, better investigate some time in the tr() misbehavior of yours.