Results 1 to 3 of 3

Thread: Cyrillic support

  1. #1
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Cyrillic support

    Hey there

    I am creating a Qt application. This program must support cyrillic fonts (or encoding). So it must take cyrillic data from a database and display that on widgets. What should be added to the program to be sure that cyrillic characters will be displayed correctly on any computer (on any systems where the main language may be not with cyrillic letters)? I was advised to add a cyrillic code page to my project but I have no clue how to do it.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cyrillic support

    The only thing you need to do is to make sure you use a font that contains appropriate glyphs. Most standard fonts do. Then just make sure you convert the data from the database into text using the same encoding the data was coded with while being stored in the database (UTF-8 seems the most reasonable choice).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: Cyrillic support


    Added after 5 minutes:


    Thank you but I still have the problem. The explaination is as follows.

    I have a string and I have to write it to my database:
    Qt Code:
    1. QString aField; // e.g. there is a text "абвгд"
    To copy to clipboard, switch view to plain text mode 
    I use QSqlQuery:
    Qt Code:
    1. query.bindValue(":aField", aField.toUtf8());
    To copy to clipboard, switch view to plain text mode 
    Then in another C++ file I try to get this string from the database with QByteArray:
    Qt Code:
    1. QByteArray aField_ = q.value(0).toByteArray();
    To copy to clipboard, switch view to plain text mode 
    Then I make a codec:
    Qt Code:
    1. QTextCodec* aCodec = QTextCodec::codecForName("UTF-8");
    To copy to clipboard, switch view to plain text mode 
    Here I convert QByteArray to QString:
    Qt Code:
    1. QString aField = aCodec->toUnicode(aField_);
    To copy to clipboard, switch view to plain text mode 
    Now I put the string to the cell of QTableWidget:
    Qt Code:
    1. item = new QTableWidgetItem(aField);
    2. ui.tableWidget->setItem(rowNumber, 1, item);
    To copy to clipboard, switch view to plain text mode 

    Latin characters are displayed okay but cyrrilic are like strange symbols.

    What I did wrong?
    Last edited by tehman; 7th February 2012 at 13:15.

Similar Threads

  1. Qt App on ARM with X11/KDE Support
    By puneet.narsapur in forum Newbie
    Replies: 5
    Last Post: 16th January 2014, 16:22
  2. SQL support for QT
    By Yayati.Ekbote in forum Newbie
    Replies: 2
    Last Post: 2nd March 2010, 15:57
  3. Does Qt 4.6 for S60 support OMA DRM
    By coco in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd February 2010, 03:06
  4. GIF support
    By talk2amulya in forum Qt Programming
    Replies: 4
    Last Post: 10th February 2009, 08:57
  5. MNG Support
    By Kruti in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 14th June 2006, 01:13

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.