Results 1 to 16 of 16

Thread: validation on an IP address

  1. #1
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default validation on an IP address

    validating an IP address by setting mask and using regular expression and validator.
    But most important is that it should shows the IP address dialog as ( . . . ) not like this000.000.000.000.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: validation on an IP address

    Have you tried searching the forum?

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: validation on an IP address

    Hi, here from my firefox bookmark: title "Ip Address Validation"
    http://www.qtcentre.org/forum/f-qt-p...tion-6228.html

  4. #4
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    Hi,

    i have gone through it but i couldnt find the solution .

    i did this thing by first setting mask then creating a regular exp and after that setting the validator. but it would accept the data but shows the ip dialog as 000.000.000.000 and i need that it must be ( . . . ).

  5. #5
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    hey hi, can u send me the regular expression for an IP address which takes values from 0 to 255.
    thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: validation on an IP address

    What's wrong with the link you were given?

  7. #7
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    hi ,that was not working. the line edit box couldnt accept the regular expression when i used it with input mask.

    can u tell me the other way of doing this?

    means by deriving a class and use a function to validate an ip address.

    please help me out.

    thanks

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: validation on an IP address

    Well... you can't use it with an input mask. But you can validate the address without dots and insert them using fixup.

  9. #9
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    hi, can u write a little bit code which shows how to use fix up.

  10. #10
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    i hav created a regular expression without using input mask . it can accept all right nos. but for example when i write 32 then it cant take any no. it is right as it wait for .(dot) to put on but is there any way that when i write any no. whete one , two or max. three digits then it shows a message that put dot now, so that user know that now its the time to put dot.

    please help me out.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: validation on an IP address

    Subclass QValidator and reimplement both validate and fixup. Fixup can work in such a way that if you enter four digits in a row, it places a dot before the last digit.

  12. #12
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    hi, can u write a little bit code for how to subclass Qvalidator and how to use Fix up and validate for an line edit box which takes valid IP address.

    please help me out

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: validation on an IP address

    Here you go, something for a start.
    Attached Files Attached Files

  14. #14
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: validation on an IP address

    thanks for that file.

    But there is some problem, i have created a lineEdit box and i am not able to understand how could i connect my Line Edit box with the code given by you so that it could take values .

    please help me out.

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: validation on an IP address

    I don't know how your code looks like... At the end of the file I attached you'll find (in main()) a line that sets the validator for the line edit.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: validation on an IP address

    {moved three posts to: Two Byte character Support}

    Please, don't ask two unrelated questions in one thread.

Similar Threads

  1. Ip Address Validation
    By bruccutler in forum Qt Programming
    Replies: 26
    Last Post: 3rd November 2010, 03:58
  2. How to display My Current System IP Address...???
    By maveric in forum Qt Programming
    Replies: 8
    Last Post: 4th August 2008, 17:22
  3. Native Mac Address
    By genny77 in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2007, 10:02
  4. Unable to resolve the IP address. ( Qt 3.)
    By joseph in forum Qt Programming
    Replies: 18
    Last Post: 5th July 2007, 12:02
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.