Function to set Text as superscript or subscript or change the text color of particular alphabet
-
I would like to set my Text as superscript or subscript or change the text color of particular alphabet. Is there any in-built function in QT. I found examples to change the background color of particular alphabet, But it didn't help me
Note: I am not using any form or qml for design. -
Hi!
I am not using any form or qml for design
So, how do you render your text?
-
Hi!
I am not using any form or qml for design
So, how do you render your text?
@Wieland here is my code
textWin = new QLabel(parent); textWin->setGeometry(xPos, yPos, widthWin, heightWin); textWin->setText("Welcome");// here i pass textI use this QLabel in many places and change the text according to my need. In some places I need subscript example: O2
-
QLabelsupports a subset of HTML. You can usesubandsuptags:ui->label->setText("<sub>Low</sub>Normal<sup>High</sup>");
-
QLabelsupports a subset of HTML. You can usesubandsuptags:ui->label->setText("<sub>Low</sub>Normal<sup>High</sup>");
-
I just copy & pasted that from my editor, you don't need a
uiobject:textWin = new QLabel(parent); textWin->setGeometry(xPos, yPos, widthWin, heightWin); textWin->setText("<sub>Low</sub>Normal<sup>High</sup>");// here i pass text -
I just copy & pasted that from my editor, you don't need a
uiobject:textWin = new QLabel(parent); textWin->setGeometry(xPos, yPos, widthWin, heightWin); textWin->setText("<sub>Low</sub>Normal<sup>High</sup>");// here i pass text -
Same, you can use HTML:

setText("<sub><font color='purple'>Low</font></sub>Normal<sup><font color='orange'>High</font></sup>")