How to get a superscript in Qt Creator for label text?
I am trying to create a superscript of a 2 to show something is squared for the units label that comes after a field the user supplies in my dialog. I am using Qt Creator v2.0.1 on Windows. The QLabel has a text field and a textFormat field. I attempted to solve this by setting the textFormat combobox to RichText a开发者_StackOverflow社区nd then set the textFormat field to be: "µm{\super 2}" however, when previewing my dialog, the text is taken literally and not as RichText and thus there is no superscript 2 but instead the '{super 2}' with the backslash removed. I also tried escaping the backslash with '{\super 2}' but I then the literal '{\super 2}' when previewing the dialog.
How can I specify the superscript to Qt Creator so that my dialog preview shows the superscripted 2?
Here is how I want it to look: µm2
Apparently html works (not sure why RichText did not):
µm<sup>2</sup>
I find another easier way which is similar to @WilliamKF solution but it is easier for me.
for example, we have one QLabel in our UI like this :
- For adding I right-click on that label and choose
Change rich text ...
and I will see this Dialog.
- There I can easily write what I want and add superscript like this:
Then if I click Ok I have what I want and also I can choose source
to see HTML tags :
<html><head/><body><p><span style=" font-size:16pt;">µm</span><span style=" font-size:16pt; vertical-align:super;">2</span></p></body></html>
精彩评论