[Qt-interest] QLineEdit sizeHint question.

David Boosalis david.boosalis at gmail.com
Fri Jan 22 16:00:00 CET 2010


Might try either one of the following:
setMinimumWidth(int);
setFixedWidth(int);



On Wed, Jan 20, 2010 at 12:40 AM, phil prentice <philp.cheer at talktalk.net>wrote:

> Hi
>  I'm slowly porting over a Motif X11 application to QT.  The old
> application
> used to define a line edit window of a fixed size.  So if the width was set
> to 6 then the line edit window would be set to 6 characters.  So I am
> trying
> to use sizeHint() to achieve the same result. i.e.
>
> size.setWidth(fontMetrics().maxWidth() * 6);
>
> The result I get is not always consistent, but its always smaller.  For
> example a width of six only gives me enough room for 4 characters.  I guess
> part of the problem is the frame size + any padding.  I tried looking at
> the
> documentation but could not fine anything that might help me take account
> of
> those.
>
> One way might be to create the widget with a temporary string set to the
> character count...but is there a better way?
>
> I know it will also depend on the character width..but I'm trying to use a
> font of constant width.
>
> Any ideas?
>
> Thanks
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100122/129b2413/attachment.html 


More information about the Qt-interest-old mailing list