You are not logged in.

#1 2009-08-16 05:57:11

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

[SOLVED] How to Make a UTF-8 Compatible Application

I have been building a small GUI in Qt and have run into this issue: my widgets are not UTF-8-compatible. Here's what happens if I set my window title to "cliché:"

utf8_issue.png

Does anyone have any ideas? I'm using Qt 4.5 on KDE 4.3

Last edited by tony5429 (2009-08-16 21:37:58)

Offline

#2 2009-08-16 19:17:12

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: [SOLVED] How to Make a UTF-8 Compatible Application

The title bar of your window is not a widget, but a feature of your window manager.  You can verify this by using a different window manager or changing the fonts.  Openbox is working for me with default font settings; wmii does the same thing yours does.

The solution?  Don't use UTF-8 in window titles.  You can't predict what fonts or window managers your target audience will be using.  (Real widgets, like buttons and labels, should behave.)

Last edited by Trent (2009-08-16 19:18:31)

Offline

#3 2009-08-16 20:10:19

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

Re: [SOLVED] How to Make a UTF-8 Compatible Application

Actually, I'm having the same problem with a QPushButton (whether I use tr() or QString()):

utf8_issue2.png

Any ideas? Also, in case it matters, my locale is set to 'en_GB.UTF-8 UTF-8' in /etc/locale.gen and 'en_GB.utf8' in /etc/rc.conf.

Offline

#4 2009-08-16 20:19:44

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [SOLVED] How to Make a UTF-8 Compatible Application

Are you sure QT is UTF-8—compatible?

(I wouldn't know, since I don't do any GUI programming.)

Last edited by Peasantoid (2009-08-16 20:20:18)

Offline

#5 2009-08-16 21:37:44

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

Re: [SOLVED] How to Make a UTF-8 Compatible Application

Thanks for all the tips. I found what I needed. For anyone else who comes to this page looking for the answer, it turns out you need to use "QString::fromUtf8()" to solve the problem.

Offline

Board footer

Powered by FluxBB