Results 1 to 5 of 5

Thread: change font while writting, QGraphicsTextItem

  1. #1
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default change font while writting, QGraphicsTextItem

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: change font while writting, QGraphicsTextItem

    The text item contains a QTextDocument. You can use its API to manipulate the content the way you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change font while writting, QGraphicsTextItem

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: change font while writting, QGraphicsTextItem

    Quote Originally Posted by airglide View Post
    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()
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    airglide (23rd July 2012)

  6. #5
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: change font while writting, QGraphicsTextItem

    great, it works fine now, thank you

Similar Threads

  1. how to change the line space in QGraphicsTextItem Paint()
    By goldhappywang in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2009, 01:42
  2. How can to change the QGraphicsTextItem 's cursor width?
    By robertkun in forum Qt Programming
    Replies: 1
    Last Post: 11th August 2009, 03:49
  3. Font size in QGraphicsTextItem
    By rippa in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2008, 19:11
  4. Change Font of QListWidget to Monospace Font
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 18:23
  5. QGraphicsTextItem: handling cursor position change
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2007, 10:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.