Results 1 to 3 of 3

Thread: QLineEdit::editingFinished() doesn't work if QLineEdit is empty?

  1. #1
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QLineEdit::editingFinished() doesn't work if QLineEdit is empty?

    Hi there!

    QDialog with multiple QLineEdit fields (Qt 5.7.0 desktop application on Windows 10):

    If a QLineEdit is losing focus and it isn't empty then the signal editingFinished() is emitted.
    But if QLineEdit is empty the signal editingFinished() is not emitted. No matter if it lost focus because of tab key action or left mouse click on next or another QLineEdit field.

    Why is edingFinished() isn't emitted if the QLineEdit is empty? Whats wrong?
    Last edited by mireiner; 9th July 2016 at 00:41.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLineEdit::editingFinished() doesn't work if QLineEdit is empty?

    One reason: if the line edit has a validator and it does not return QValidator::Acceptable, or an input mask that is not matched/complete, then editingFinished() is not emitted.

  3. The following user says thank you to ChrisW67 for this useful post:

    mireiner (9th July 2016)

  4. #3
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLineEdit::editingFinished() doesn't work if QLineEdit is empty?

    ChrisW67,

    It was the validator. The last parameter of QRegularExpression had to be changed from {1,4} to {0,4} to allow empty input:
    Qt Code:
    1. QValidator *validator;
    2. validator = new QRegularExpressionValidator(QRegularExpression("[A-Z 1-5]{1,4}"), this);
    3. validator = new QRegularExpressionValidator(QRegularExpression("[A-Z 1-5]{0,4}"), this); // works
    To copy to clipboard, switch view to plain text mode 
    Thank you very much for your help!

Similar Threads

  1. Grey text in empty QLineEdit
    By Mefisto in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2017, 12:35
  2. QLineEdit empty string
    By zgulser in forum Newbie
    Replies: 4
    Last Post: 3rd August 2010, 15:18
  3. editingFinished of QLineEdit
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2009, 10:06
  4. Empty style sheet changes QLineEdit
    By mpi in forum Qt Programming
    Replies: 3
    Last Post: 15th June 2009, 21:13
  5. Default delegate displays empty QLineEdit?
    By andy.fillebrown in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2009, 14:13

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.