0

I' ve got a problem with my app. i'm beginner in Qt so I tried to make a cryptograph. Everything works fine but there is a problem with all polish characters (ó,ę,ź,ż,ą). I mean that there are squares visible not a text (QplainText).

UPDATED: problem was connected with propriate encoding, .toLatin method sometimes do not supports national characters, to provide your app having ó,ę etc. You have to change method from latin to unicode or encode on your own . This post is for all people who have problem with it. Sadly all qt forums say only about the latin method which was not good in my case

  • What do you mean there are squares? In the qt creator or a qtextedit? Normally, squares means the text renderer could not find appropriate font to reder the text. Maybe you system have no polish font installed or the polish character is not intepreted as polish character but assome unrecognized characters. – Jichao Aug 22 '15 at 11:22
  • I'm on linux so it shouln't be way that some characters are unrecognized, but it seems like it. I 've got QlineEdit where i type a text and when i click on button the converted text is shown on QPlaintextedit and there are these squares. –  Aug 22 '15 at 11:29
  • On any os, if there is no font to render a character, the character is unrecognizable(which could be sqaures). And you need provide a simplest testable example for your problem. – Jichao Aug 22 '15 at 11:35
  • So what is a solution ? –  Aug 22 '15 at 11:44
  • **provide a simplest testable example for your problem** – Jichao Aug 22 '15 at 11:59

2 Answers2

1

Ok I find a solution ! :)

Before my code looks like it

QString Encrypted;
for(int i = 0 ; i < Text.length() ;i++)
{

  Encrypted[i] = Text[--n].toLatin()-b; // where b is random int


}

I changed method from .toLatin to .unicode and all works fine ; )

0

you need to change the encoding of your code files to unicode.

see How can I embed unicode string constants in a source file?

Community
  • 1
  • 1
maazza
  • 7,016
  • 15
  • 63
  • 96