PDA

View Full Version : change font while writting, QGraphicsTextItem



airglide
20th July 2012, 17:30
hello everyone ;)

I have some textitems (a derived class) and want to change the QFont, I can do it for the whole item or just for a selected part. But I couldn't figure out how i can change the font of the text, i'm going to write without changing the whole textitem's font...

i'm writting and now i want to change the font without changing the font of the written part

thank you for your help ;)

airglide

wysota
20th July 2012, 17:32
The text item contains a QTextDocument. You can use its API to manipulate the content the way you want.

airglide
23rd July 2012, 02:54
sorry for my late reply.. ;)

Yes I've seen it but there's only the function setFont() and this sets the font of the whole widget. I've written also that you can highlight text and than change Font with textCursor() and mergeCharFormat() but how can I say from now on I want to write in Arial ... can I insert html tags or something like this? or do I have to set every new written Character a Font?

wysota
23rd July 2012, 09:12
Yes I've seen it but there's only the function setFont()
No, there is a whole API for manipulating each character of the text separately. Read the docs on QTextDocument, it's all there.



but how can I say from now on I want to write in Arial

QTextCursor::setCharFormat()

airglide
23rd July 2012, 15:09
great, it works fine now, thank you