[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    What's the size in pixels of a QString with a given QFont?
From:       Arvid Nilsson <f98ani () efd ! lth ! se>
Date:       1999-07-28 14:26:13
[Download RAW message or body]

Hi there!

How can I find out the size in pixels (width, height) of a QString painted
using a given QFont? Currently I put the QString in a QLabel and get its
sizeHint().

The purpose of this is to create a subclass of QLineEdit that will
automatically resize as the user types in text. (QLineEdit::sizeHint() is
quite useless for this purpose.)

Sometimes, the size returned by QLabel::sizeHint() is too small, and the first
character gets cut out of my LineEdit. Other times the size I get from sizeHint
is a bit too big (especially at higher font sizes).

PS: Is it okay to ask Qt-questions here on kde-devel?

-- 
	Arvid Nilsson, Sweden
	f98ani@efd.lth.se

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic