Results 1 to 2 of 2

Thread: How to get size (length, width ....) of string or char

  1. #1
    Join Date
    Mar 2006
    Posts
    20
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default How to get size (length, width ....) of string or char

    Dear Sir,
    i want to know the size (width & length or area) of string or char with all property like (bold, italic, underline, color, font & fontsize) are operating on it.

    means string or char can be considered a picture. So how can colculate its size

    Thanks & regards
    Krishna

  2. #2
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get size (length, width ....) of string or char

    Look at QFontMetrics:

    QFontMetrics fm( font() );

    int w = fm.width( edit->text() );
    // returns width in pixels

Similar Threads

  1. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  2. unable to save QCStrings properly in a buffer
    By nass in forum Qt Programming
    Replies: 13
    Last Post: 15th November 2006, 20:49

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.