PDA

View Full Version : Creating a string with subscript text



maverick_pol
7th November 2007, 17:00
Hi guys,

I have to draw some simple number in the Gscene, but the fractional part of that number should be printed as subscript.
How to create a QString containg a subscript text? For example, is it possible to create a text with subscript part and show it in the QMessageBox? I am currently looking for a solution, but maybe someone has already done it before.

Thanks.

Maverick

P.S.

I have already checked the QTextDocument(but will not work in my case)
I could create "paint" 2 texts where one would be on the left lower part of the first one, but that this is not acceptable.

Found the solution:

QMEssageBox::warning(0,QString("Upper<sub>lower</sub>"),"");

jpn
7th November 2007, 17:12
Please correct if I'm wrong but don't QMessageBox, QLabel, QGrapicsTextItem all support rich text:

Here's some <sub>subscripted</sub> text.

maverick_pol
7th November 2007, 17:13
Hi,

I have found the answer.

1. In the messageBox the solution is simple:


QMessageBox::warning(0,QString("Upper<sub>lower</sub>"),"");


Analogically we can use the HTML tags in the QTextItem to format item text.

Maverick