November 30, 2010

puelocesar puelocesar
Lab Rat
32 posts

Accents in Qml

 

Hi, I’m having problems with international accents on Qt Quick. Here is an example:

problem

And here is my code:

  1. Text {
  2.         id: corpo_texto
  3.         width: 152
  4.         height: 65
  5.  
  6.         text: "O mundo precisa se unir pra manter o #Wikileaks ativo e funcionando. Faz tempo que eu não vejo um grupo e uma iniciativa tão corajosos."
  7.         wrapMode: "WordWrap"
  8. }

How to solve this? Sorry if it’s a basic question, but I found it anywere how to solve this on Qml.

14 replies

November 30, 2010

Tobias Hunger Tobias Hunger
Area 51 Engineer
3383 posts

Which encoding is your source file in? I think Qt Quick expects its strings in utf-8 encoding.

November 30, 2010

thatbloke thatbloke
Lab Rat
2 posts

Hi, I had a similar problem recently when trying to use Unicode characters. For me, the problem was that the QML file itself was not in UTF-8 format. Ensure it is in UTF-8 format and then try re-running the app.

It does raise the issue of a possible bug, though – even if the file is not in UTF-8 format you can still type in non-ascii characters and see them perfectly fine in the creator, even after saving the file, giving the impression that the text has been saved correctly, when in fact it hasn’t been.

November 30, 2010

puelocesar puelocesar
Lab Rat
32 posts

Yes, that’s it. Thanks for the help folks!

The problem is that Qt Creator is creating the files using the system’s default, which is ISO on Windows. I had to close it on Qt Creator and convert the file in Notepad++, and set Qt Creator to always use UTF8. Now it’s everything fine.

By the way, shoudn’t Qt Creator be set to UTF8 by default then?

November 30, 2010

Tobias Hunger Tobias Hunger
Area 51 Engineer
3383 posts

puelocesar: This is mostly a windows issue as all other OSes default to UTF-8 anyway. If we would use UTF-8 in creator by default then you would get the garbage you saw in your QML application in creator… so that is not really an option:-/

I wish windows would finally give up on the code pages and switch to unicode by default… they do support unicode ever since Win 95 times IIRC.

December 2, 2010

paulo paulo
Ant Farmer
174 posts

puelocesar: you don’t need Notepad++ only select the Select Encoding option located in the Edit Menu of Qt Creator.

Select Encoding

December 2, 2010

puelocesar puelocesar
Lab Rat
32 posts

Cool! I didn’t found that! Thanks for the tip

December 15, 2010

syrianzoro syrianzoro
Lab Rat
63 posts

If you use MsWindows

CMD>lupdate YourText.qml -ts YourText.ts

1 – open YourText.ts in Linguist(C:\Qt\4.7.0\bin\linguist.exe)
2- provide a translation
3- create the release file YourText.qm.

CMD> qmlviewer -translation YourText.qm YourText.qml

 Signature 

Qt is the future

December 16, 2010

mbrasser mbrasser
Lab Rat
452 posts

Tobias: Are QML files generated by creator on Windows UTF-8 by default? If not, can they be?

December 20, 2010

kkoehne kkoehne
Ant Farmer
63 posts

I opened a bug for qtcreator that this should be fixed in 2.2: http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3424

July 10, 2011

changsheng230 changsheng230
Lab Rat
128 posts

Will keep track of it. Nice discussion.

 Signature 

Chang Sheng
常升

July 10, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

changsheng230, what do you mean? discussion was ended half a year ago, bug is already closed. Please, don’t necropost.

July 10, 2011

changsheng230 changsheng230
Lab Rat
128 posts

This might not be a suitable action, sorry for that. However, I comment it for the sake of archving my “favorite” discussion so that I was able to find it in a faster way. Moreover, I will update my creator to 2.2.0 to have a try whehter it is OK.

Denis Kormalev wrote:
changsheng230, what do you mean? discussion was ended half a year ago, bug is already closed. Please, don’t necropost.

 Signature 

Chang Sheng
常升

July 10, 2011

Eddy Eddy
Area 51 Engineer
1563 posts

Hi Changsheng,

What you can do to find the articles back you like is using the rate up button. In the future there will be a way to filter those you have rated up.

At this moment you could add the page to your bookmarks in your favorite web browser.

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

July 10, 2011

changsheng230 changsheng230
Lab Rat
128 posts

Thank a lot for your comments

Eddy wrote:
Hi Changsheng, What you can do to find the articles back you like is using the rate up button. In the future there will be a way to filter those you have rated up. At this moment you could add the page to your bookmarks in your favorite web browser.

 Signature 

Chang Sheng
常升

 
  ‹‹ ListView or animating the ’X’ property      [bug] Component id cannot start with underscore ››

You must log in to post a reply. Not a member yet? Register here!