Results 1 to 3 of 3

Thread: How to embed unicode or utf8 symbols in a tooltip

  1. #1
    Join Date
    Mar 2006
    Location
    Troy, Michigan, USA
    Posts
    17
    Thanks
    2
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default How to embed unicode or utf8 symbols in a tooltip

    I am trying to set a tooltip that will contain the Mac command key symbol \u2318 but can not figure out how to do it.

  2. #2
    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 embed unicode or utf8 symbols in a tooltip

    Putting the character in a QString, setting the tooltip, or making sure the font being used has the ⌘ glyph. Which bit is the problem?

    The character is QChar(0x2318). There are a few ways to easily insert it.
    Qt Code:
    1. #include <QApplication>
    2. #include <QString>
    3. #include <QLineEdit>
    4.  
    5. int main(int argc, char **argv)
    6. {
    7. QApplication app(argc, argv);
    8. const QString text = QString("Test with %1 symbol").arg(QChar(0x2318));
    9. // Or, if you can type it then chances are this will work
    10. // const QString text = QString::fromUtf8("Test with ⌘ symbol");
    11.  
    12. l.setText(text);
    13. l.setToolTip(text);
    14. l.show();
    15. return app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChrisW67; 31st May 2013 at 03:20.

  3. #3
    Join Date
    Mar 2006
    Location
    Troy, Michigan, USA
    Posts
    17
    Thanks
    2
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to embed unicode or utf8 symbols in a tooltip

    That was it! Thanks!

Similar Threads

  1. decoding from utf8
    By pcaeiro in forum Qt Programming
    Replies: 6
    Last Post: 25th August 2009, 12:51
  2. UTF8 and QStandardItem?
    By alexandernst in forum Newbie
    Replies: 17
    Last Post: 26th July 2009, 18:29
  3. UTF8 and ByteOrderMark (BOM)
    By SidGBF in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2008, 22:25
  4. Problems with Unicode(UTF8)
    By cristiano in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2006, 12:33
  5. Utf8 problems
    By cristiano in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2006, 00:14

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
  •  
Qt is a trademark of The Qt Company.