Results 1 to 3 of 3

Thread: Adding greek text to a QLabel by code

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Adding greek text to a QLabel by code

    Hello!

    I want to display text characters in a QLabel, something like this:

    Qt Code:
    1. ui->label->setText("Φ");
    To copy to clipboard, switch view to plain text mode 

    I'm not very familiar with special characters in Qt; every time till now I've being using ASCII hexa characters to set special chars, but now it would seem I'll have to use UTF-8. The problem is that I'm really not familiar with text codes and encodings and the like (something that is in my TOLEARN list of Qt) and I need this quickly

    Doing some research, I found this thread: http://www.qtcentre.org/threads/8108-greek-symbols (and also http://www.qtcentre.org/threads/3467...n-a-text-Label), but nothing of the provided methods worked for me

    I'ld also like to add that it should be "quick insertions" of special characters (greek text), so I'ld like to avoid whole-code changes such as by using method as QTextCodec::setCodecForCStrings() or anything of the like that has a more "global scope".


    Thanks for any help,

    Momergil


    Details: using Qt 4.8 and Linux
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding greek text to a QLabel by code

    No one have a clue about this?
    May the Lord be with you. Always.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding greek text to a QLabel by code

    Well, the easiest way is to have the source file in UTF-8 encoding and use QString::fromUtf8().


    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    Momergil (6th November 2015)

Similar Threads

  1. Replies: 15
    Last Post: 31st January 2020, 19:25
  2. geting QLabel text ontop of other QLabel displaying image
    By krystosan in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2013, 18:35
  3. Adding QLabel to QMainWindow statusbar
    By graciano in forum Newbie
    Replies: 6
    Last Post: 10th November 2013, 11:01
  4. QGraphicsLayout: Problems adding QLabel
    By SneakyPeterson in forum Newbie
    Replies: 1
    Last Post: 1st July 2010, 13:31
  5. Replies: 2
    Last Post: 7th January 2007, 22:07

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.