How to show math symbols like theta
Asked Answered
B

2

7

I'm trying to find a way to show math symbols such as \theta, \phi, \dot{\theta}, ..., etc. I couldn't find a way to show these letters in my plot. Does qcustomplot support math symbols? I've tried the following line but very few letters show up but the rest doesn't.

ui->customPlot1->graph(0)->setName(QString("\u0024"));

Baize answered 17/4, 2016 at 3:51 Comment(5)
You need to create a QString properly. doc.qt.io/qt-4.8/qstring.html#fromUtf8 doc.qt.io/qt-4.8/qstring.html#fromUtf16Convertite
The correct name for these symbols is greek. Greek symbols are available in some encodings. UTF8 is one of them. As n.m. noticed you just need to properly create a QString from unicode string.Lightfingered
@teivaz, I used theta as an example. Not all math symbols are Greek.Baize
@Baize If you're looking for analogue of LaTex than it seems that there is no support for it right now.Lightfingered
@Baize Does your font support those symbols?Jeremiahjeremias
B
2

In my Qt GUI in Windows 7, the following line worked

 title->setText(QString::fromWCharArray(L"\u03B8\u2081(t) vs \u03B8\u2081\u1d48(t)"));

The result is

enter image description here

where \u03B8 is \theta, \u2081 is subscript one, and \u1d48 is subscript d. For the rest of charaters, see this link.

Baize answered 20/4, 2016 at 22:8 Comment(0)
P
4

What you are looking for is:

ui->customPlot1->graph(0)->setName(QString::fromUtf8("\u03B8"));

This for example will give you the small letter theta. Use UTF-8 Encoding Table and Unicode Characters to get your desired letters code.

Photokinesis answered 17/4, 2016 at 12:41 Comment(5)
This is exactly what I've done but didn't work. Your code shows me a question mark in my plot.Baize
@Baize If you can post more from your code and maybe some more information about that question mark so I will be able to look for the reason. I am currently also working on qcustomplot code and I just tried this on my plot and it worked.Photokinesis
@Baize what are your OS and compiler?Convertite
@n.m. Windows 7 and Qt.Baize
Windows doesn't particularly like utf8, you may have to type each individual byte in the \xPQ notation. Or try fromUtf16 and a wide string.Convertite
B
2

In my Qt GUI in Windows 7, the following line worked

 title->setText(QString::fromWCharArray(L"\u03B8\u2081(t) vs \u03B8\u2081\u1d48(t)"));

The result is

enter image description here

where \u03B8 is \theta, \u2081 is subscript one, and \u1d48 is subscript d. For the rest of charaters, see this link.

Baize answered 20/4, 2016 at 22:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.