Results 1 to 2 of 2

Thread: QLineEdit-how to validate immediately?-connection problem

  1. #1
    Join Date
    Jun 2007
    Location
    India
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QLineEdit-how to validate immediately?-connection problem

    Hello all,
    I am trying to build a small app which has several IP Address fields. I have found the validation method [some kind of work around ] which i have put as Dialog::validateIP()

    Now, i tried to connect the LineEdit to the function using many available signals. But none of them worked. Could anyone please tell what the problem is?

    connect statements i have tried:
    Qt Code:
    1. connect(sourceIPEdit, SIGNAL(lostFocus()), this, SLOT(validateIP()));
    2. //connect(srcipEdit, SIGNAL(editingFinished()), this, SLOT(validateIP()));
    3. //connect(srcipEdit, SIGNAL(textChanged()), this, SLOT(validateIP()));
    To copy to clipboard, switch view to plain text mode 


    Interesting thing is that if i connect the same func to a pushButton, it does work! What i am trying to achieve is to tell the user immediately after he left the sourceIPEdit field that he did something wrong. [Just like in some webforms where you get immediate feedback that, say for example, some username you have given is 'available']

    Also, is there any way around to give a *silent* feedback to the user? without popping up a nagging error messagebox everytime?

    I am using Qt 4.2.2 from Windows and Linux.

    Deepak

  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: QLineEdit-how to validate immediately?-connection problem

    Why not use a subclass of QValidator instead of hand-crafted solution? There are a few IPV4 validators available on the forum, if you search for IPV4Validator, you'll surely find them.

Similar Threads

  1. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 16:13
  2. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 11:22

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.