Results 1 to 7 of 7

Thread: How to show Unicode characters on MS Windows?

  1. #1
    Join Date
    Jan 2006
    Location
    Southern Europe
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to show Unicode characters on MS Windows?

    I need to show Unicode characters in a QLabel. This code works fine on Debian, but on Windows I just get a square.
    FWIW, the browser does show this character when used in a webpage, and I can copy/paste it in Wordpad, so I guess it's not a font issue.
    What am I missing?

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QLabel>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QLabel label(QChar(10269)); // ⠝ (U+281D) is points 1,3,4,5 in Braille
    9. label.show();
    10.  
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2012
    Location
    Tver, Russia
    Posts
    9
    Thanks
    1
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to show Unicode characters on MS Windows?

    Hi, I think this is font issue, try to install Dejavu Sans and set font using
    Qt Code:
    1. label.setFont(QFont("Dejavu Sans"));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Southern Europe
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to show Unicode characters on MS Windows?

    Quote Originally Posted by Surendil View Post
    Hi, I think this is font issue, try to install Dejavu Sans and set font using
    Qt Code:
    1. label.setFont(QFont("Dejavu Sans"));
    To copy to clipboard, switch view to plain text mode 
    Oh, that works!! Thanks! :-)

    Should I just add that line as is, or should it only apply to the Windows build?
    In the latter case, what would be the correct method to do it?

  4. #4
    Join Date
    Mar 2012
    Location
    Tver, Russia
    Posts
    9
    Thanks
    1
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to show Unicode characters on MS Windows?

    Hmm I think it would be better to apply this only to Windows build (you said in Linux it works well). You may wrap this code with:
    Qt Code:
    1. #ifdef Q_OS_WIN32
    2. label.setFont(QFont("Dejavu Sans"));
    3. #endif
    To copy to clipboard, switch view to plain text mode 
    Look at http://doc.qt.io/qt-4.8/QtGlobal for platform preprocessor definitions and don't forget to include Dejavu (or any other font you want use for Braille) into your distribution package for Windows.

  5. #5
    Join Date
    Jan 2006
    Location
    Southern Europe
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to show Unicode characters on MS Windows?

    Thanks for your pointer

    Quote Originally Posted by Surendil View Post
    don't forget to include Dejavu (or any other font you want use for Braille) into your distribution package for Windows.
    That must be done in the installer, right?
    I just began developing my app, and didn't explore yet the available options (Nullsoft Scriptable Install System, Inno Setup, WiX...).

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to show Unicode characters on MS Windows?

    I believe that Windows 7 includes Braille characters in its Segoe UI Symbol font, but that earlier versions do not. So you have some Windows versions that require a third party font, and others that don't There are some free fonts containing just the Braille patterns: http://www.alanwood.net/unicode/font...raillepatterns

  7. #7
    Join Date
    Jan 2006
    Location
    Southern Europe
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to show Unicode characters on MS Windows?

    Quote Originally Posted by ChrisW67 View Post
    I believe that Windows 7 includes Braille characters in its Segoe UI Symbol font, but that earlier versions do not. So you have some Windows versions that require a third party font, and others that don't
    Thanks for your comment.
    DejaVu Sans is actually doing the trick (tested on both Windows 7 and Windows XP).

Similar Threads

  1. QString to unicode characters
    By jsmax in forum Newbie
    Replies: 1
    Last Post: 19th September 2011, 11:41
  2. How to show Chinese eudc characters?
    By changpotsung in forum Qt Programming
    Replies: 0
    Last Post: 6th July 2011, 18:33
  3. Replies: 11
    Last Post: 21st February 2011, 18:54
  4. Unicode/ASCII characters in QTextStream
    By yren in forum Qt Programming
    Replies: 3
    Last Post: 23rd November 2009, 19:25
  5. Insertion of unicode characters into database oracle through pro c
    By hemananda choudhuri in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2007, 11:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.