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"));

CroCo
  • 5,531
  • 9
  • 56
  • 88
  • 1
    You need to create a QString properly. http://doc.qt.io/qt-4.8/qstring.html#fromUtf8 http://doc.qt.io/qt-4.8/qstring.html#fromUtf16 – n. m. could be an AI Apr 17 '16 at 07:34
  • 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. – Teivaz Apr 17 '16 at 10:50
  • @teivaz, I used theta as an example. Not all math symbols are Greek. – CroCo Apr 17 '16 at 15:29
  • 1
    @CroCo If you're looking for analogue of LaTex than it seems that there is no support for it right now. – Teivaz Apr 17 '16 at 15:52
  • @CroCo Does your font support those symbols? – Itay Grudev Apr 19 '16 at 12:03

2 Answers2

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.

A. Sarid
  • 3,916
  • 2
  • 31
  • 56
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.

CroCo
  • 5,531
  • 9
  • 56
  • 88