Results 1 to 3 of 3

Thread: QT Designer : Accept only numbers for IP Address

  1. #1
    Join Date
    Aug 2017
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default QT Designer : Accept only numbers for IP Address

    Hi Qtfolks,

    I am developing a QT GUI which accepts the IP Address, MAC address and Port number and validates them. The designer is as follows.

    QT_Old.jpg


    But I want the Line edit for IP address and MAC Address should be as follows.

    QT_New.jpg

    Note : Newbie for the QT, please excuse if question doesn't make sense.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT Designer : Accept only numbers for IP Address

    QLineEdit has this and some o ther validators built in, look at the docs - look for inputMask there.
    Or you can make your own validator with QValidator
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT Designer : Accept only numbers for IP Address

    Quote Originally Posted by QT_Vishwanath View Post
    Hi Qtfolks,

    I am developing a QT GUI which accepts the IP Address, MAC address and Port number and validates them. The designer is as follows.

    QT_Old.jpg


    But I want the Line edit for IP address and MAC Address should be as follows.

    QT_New.jpg

    Note : Newbie for the QT, please excuse if question doesn't make sense.
    Qt Code:
    1. QRegExp rx("\\d+");
    2. QLineEdit *myEdit = new QLineEdit();
    3. myEdit ->setValidator(validator);
    4. this->setCentralWidget(myEdit );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QML accept self-singed SSL certificate
    By KeineAhnung in forum Newbie
    Replies: 1
    Last Post: 4th December 2015, 14:10
  2. LineEdit should not accept only zero's
    By sai_3289 in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2013, 08:42
  3. Accept/Not accept symbols in QLineEdit
    By naturalpsychic in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2012, 17:26
  4. How to set QLineEdit to accept only ASCII...
    By cydside in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2011, 09:55
  5. accept() and reject() slots
    By poporacer in forum Newbie
    Replies: 3
    Last Post: 19th August 2010, 02:07

Tags for this Thread

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.