PDA

View Full Version : Changing QLineEdit's size



Wasabi
18th October 2010, 15:11
This is a pretty silly question, but it's one I can't find an answer in the documentation:

How do I change the size of a QLineEdit. I know it's a "line"-edit and thus can only be one line long (which is why I chose it), but what I want to do is change its length. Currently it fits around fifteen characters, but I only need it to fit... two or three.

I've tried QLineEdit::resize(), but that made no difference.

high_flyer
18th October 2010, 15:16
Is the QLineEdit in a layout?
If so, the layout will control its size.

Wasabi
18th October 2010, 15:19
Indeed it is. How can I alter its size manually, though? The layout is clearly doing quite a poor job at it.

Lykurg
18th October 2010, 15:37
You can calculate the needed with using the font metrics and content margins and set a fixed size.

Wasabi
18th October 2010, 17:16
How do I do that, though? The only size-altering function I know is resize(), but that isn't changing anything.

Lykurg
18th October 2010, 17:26
Ehm, then go to the documentation and search for "fixed" and "size" or "width" since that is what you want. You can also try the combination "fixedwidth".

If you don't know how to turn your computer on, I can also help you with that ;)


Come on guys, dare to use the documentations search functions!

Wasabi
18th October 2010, 17:40
I searched for size-related functions like mad, going as far back as QObject. However, most of them seemed irrelevant to the case in hand.

Also, I'm an idiot. >.>

Lykurg
18th October 2010, 18:46
So you have found (to leave at least one miracle ->)???::setFixedWidth()?