Results 1 to 4 of 4

Thread: QString size

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QString size

    Hi,

    How can I know the size in pixels will a QString be?
    For example, a QString having "ERROR" as text, wich will the minimum size that I have to set to the QLabel to ensure that will be displayed?
    The text showed into the QLabel will be modified but I know that "ERROR" is the max length word.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QString size

    Well, you can calculate it with QFontMetrics, but there was no need if the label was in a layout.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QString size

    Hi,

    but there was no need if the label was in a layout
    If the label is in a layout it will be resized as I change the text, ok? So, I don't want it to be resized every time, I want to be the maximum text size.

    Will take a look at QFontMetrics.

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QString size

    If the label is in a layout it will be resized as I change the text, ok? So, I don't want it to be resized every time, I want to be the maximum text size.

    Will take a look at QFontMetrics.
    You break the layout; if exist for label.
    The above member of QFontMetrics help you.
    Last edited by jpn; 24th January 2008 at 06:00. Reason: reformatted to look better
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

Similar Threads

  1. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  2. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.