user2750729
user2750729

Reputation: 43

How to insert specific symbols in qt widgets

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

Upvotes: 4

Views: 5501

Answers (2)

Marek R
Marek R

Reputation: 37697

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!

Upvotes: 4

Guilherme Bernal
Guilherme Bernal

Reputation: 8293

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).

Upvotes: 1

Related Questions