[resolved] How to display a string in different font size
General and Desktop
3
Posts
2
Posters
738
Views
2
Watching
-
wrote on 25 May 2015, 05:32 last edited by stuartx
Hi, I want to display a string in QGraphicsScene in different font size, eg. "100mph". I can achieve that by putting each piece in a different string. For simplicity, is there any way to display it in a single string?
Thanks.
-
Hi, I want to display a string in QGraphicsScene in different font size, eg. "100mph". I can achieve that by putting each piece in a different string. For simplicity, is there any way to display it in a single string?
Thanks.
Hi @stuartx,
You can use QGraphicsTextItem and add it toQGraphicsScene
. It has setHtml wherein you can set the text in HTML format way. So,QGraphicsTextItem *txt = new QGraphicsTextItem; txt->setHtml("<font size=\"6\">100</font><I>mph</I>"); scene->addItem(txt);
-
wrote on 27 May 2015, 15:03 last edited by stuartx
Hi p3c0, Thank you very much. Your method works well.
1/3