PDA

View Full Version : beta and Alpha and gama Symbols In QLabel



robel
14th October 2015, 10:17
HI,
i want to use the symbols of alpha, beta and gama as label of my button
aftre search in the internet i found just the definition of alpha symbole


alpha = QChar(0xb1, 0x03);



can somone help me to get beta and gama ?

yeye_olive
14th October 2015, 10:48
The Unicode code points of α, β, and γ are U+03B1, U+03B2, and U+03B3, respectively. You could initialize QChars with with QChar(0x3b1), QChar(0x3b2), and QChar(0x3b3).

However, you can probably just use the characters in source code directly, e.g. with

label->setText("Some text containing α, β, and γ");
in Qt 5, provided your source file is encoded in UTF-8. If you use Qt 4 and your source file is encoded in UTF-8, you can do

label->setText(QString::fromUtf8("Some text containing α, β, and γ"));
instead.

robel
14th October 2015, 10:53
Thank you
i wil try it

Radek
14th October 2015, 18:25
Note: Unless you have α, β, and γ somewhere on your keyboard, you will need to create the string:
(1) Using clipboard, copy a string with α, β, and γ on the clipboard then copy it to your code,
(2) or creating the string in your code


QString tmpstring = "Some text containing "

tmpstring += QChar(0x3B1);
tmpstring += ", ";
tmpstring += QChar(0x3B2);
tmpstring += ", and ";
tmpstring += QChar(0x3B3);

label->setText(tmpstring);