How to insert specific symbols in qt widgets

Viewed 4841

I want to make buttons with specific math symbols, like square root, delta, sigma, pi, etc. How to do this? I'm using Qt 5 and unicode. Thanks

2 Answers

Just take any Unicode documentation and define required constants:

const QChar MathSymbolSquereRoot(0x221A);
const QChar MathSymbolPi(0x03A0);
const QChar MathSymbolDelta(0x0394);
const QChar MathSymbolSigma(0x03A3);

Remember that you have to use font which support those Unicode characters!

If you can write your expression as a unicode string, just use it as the button's label. (See QString::fromUtf8(...). Otherwise (i.e. you have a complex expression) you can save it to a image and display as the button's icon (remove the text).

Related