PDA

View Full Version : How to create line edit or text edit box similar to "Setting IP address in Windows"



katta_ashish
24th August 2010, 10:20
I have to create a box which will accept text in the form of IP address that is it should show " . . . " at the opening and then it should accept IP address from the user in the form of 192.168.23.54 where it should be in the range of 0 to 255.Anybody having any idea regarding this then please help me....Thank you in advance

squidge
24th August 2010, 14:27
Method 1: Use a mask on a QLineEdit
Method 2: Use four QLineEdit's and have the '.'s as QLabels
Method 3: Subclass QLinEdit and override paintEvent to nicely align the ip address (you can also do the validation in the subclass too)

If you want to allow copy/paste of the ip address, you should rule out method 2, but thats the way Windows IP control works (tab doesn't work properly there either).

katta_ashish
26th August 2010, 08:59
Thanx for your help...I have done it using multiple line edit but now i want one more thing that is when three digits are input by user then the cursor should automatically go to next line edit....Can any one help me regarding that.

nightghost
26th August 2010, 09:57
You could connect to "textChanged()". If 3 digits were entered set the focus to the next QLineEdit.