PDA

View Full Version : QLineedit mask



sudhansu
11th March 2010, 14:46
Hi All
I've a lineedit control . i need to use it as a IP input field. i ve given the like below.

setInputMask("000.000.000.000; X");

But instead of X i need to show blank space only, till i give input to this field. and all 3 dots should ve same gap.. how to do it? Plz help
thanx.

zgulser
11th March 2010, 14:49
Try this; setInputMask("000.000.000.000 X;");

sudhansu
11th March 2010, 15:47
Try this; setInputMask("000.000.000.000 X;");

Ya its working. but i need the gap between should be same. like

| . . . . | ----------> assume that this is my QLineedit. so the space is equally divided.

zgulser
11th March 2010, 15:50
Can you show/display what you want with numbers? Please visualize it.

sudhansu
12th March 2010, 04:24
Can you show/display what you want with numbers? Please visualize it.

I want a linedit for entering IP address. and the gap betewwn all . should be equal, as in attachment. and it sholud display blank filed. Please chech the attached ui.

zgulser
12th March 2010, 08:12
Hey, please don't misunderstand me but I couldn't get the point of what you trying to do...Don't send me another .ui file:). Just type simply..

But as far as I understand you're trying the following

0000 . 0000 . 0000 . 0000 ( if not please just type what you want with numbers)

ChrisW67
12th March 2010, 08:40
I think that the OP wants a text box into which an IP address can be typed. Before anything is entered the OP wants the text box to look like:


+---------------+
| . . . |
+---------------+

and have the digits fill in around the dots as the user types:


+---------------+
|192. 0. 2. 34|
+---------------+

Setting the input mask to "000.000.000.000" (perhaps "009.009.009.009" or "900.900.900.900") should give the space fillers, i.e. space is the default if there is none specified. You would also need a validator to check the range of the digits entered.

The OP also seems to require that, when empty, the dots should be evenly spaced. The dots will move about as typing continues unless a monospaced font is used for the line edit. Set the width of the line edit based on the calculated width of the mask in that font and all should be good.

Lykurg
12th March 2010, 08:46
I want a linedit for entering IP address. and the gap betewwn all . should be equal, as in attachment. and it sholud display blank filed.You have to set a fixed size to your line edit. To calculate that use QFontInfo.

zgulser
12th March 2010, 08:58
You mean variable size for IP address fields Chris?

sudhansu
12th March 2010, 12:26
You have to set a fixed size to your line edit. To calculate that use QFontInfo.

lineedit size is fixed to 121*26. and font is A[Sans, 10]. how to calculate the size using QFontInfo?

Lykurg
12th March 2010, 12:58
ups, I wanted to say QFontMetrics. See QFontMetrics::width() with "999.999.999.999".

wysota
12th March 2010, 13:10
Set a monospaced font on the line edit.