Results 1 to 4 of 4

Thread: Limiting text inside a QGraphicsItem's item?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Limiting text inside a QGraphicsItem's item?

    You have to check the width() of your QFontMetrics instance initialized with a QFont .

    I used it to write over a QGraphicsItem on a single line.
    But in ordrer to find the right size of the font, I need to loop and check by changing the font size with setPixelSize until it fits my boundaries rect size.

    I didn't find any method in the documentation to get the right size from a pixel size direclty.


    Be aware that if your item is scaled, the label you are writing will be scale too.

  2. The following user says thank you to scascio for this useful post:

    qtzcute (16th September 2009)

  3. #2
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Limiting text inside a QGraphicsItem's item?

    Thanks scascio and Boran. I worked it out finally.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTreeWidget get a text from child item
    By vcp in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 17:36
  3. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30
  4. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03
  5. Replies: 1
    Last Post: 17th March 2006, 08:19

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.