Results 1 to 2 of 2

Thread: Empty Line Edit Validation

  1. #1
    Join Date
    Oct 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Empty Line Edit Validation

    Hello,


    I'm newbie at Qt.

    I want to control line edit to understand it is empty or not, when a push button is pressed. How can I implemet it ?

    Best regards....

  2. #2
    Join Date
    Jul 2011
    Location
    Brasil
    Posts
    39
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Empty Line Edit Validation

    Hello!!

    From line edits you can take the text by using QLineEdit::text(). Once you done that, you will receive a http://doc.qt.io/qt-4.8/QString, which has the isEmpty method.

    Take a look:
    Qt Code:
    1. QLineEdit * le=new QLineEdit();
    2. if(le->text().isEmpty()){
    3. //no text inside... Or only spaces
    4. }else{
    5. //some valid non-space text inside.
    6. }
    To copy to clipboard, switch view to plain text mode 

    HTH.

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Replies: 3
    Last Post: 26th August 2010, 08:57
  3. Adding validation to a QListView's edit mode
    By MattT in forum Qt Programming
    Replies: 10
    Last Post: 1st August 2010, 01:53
  4. simple QDialog with Line validation
    By ericV in forum Qt Programming
    Replies: 2
    Last Post: 17th August 2009, 10:10
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.