Results 1 to 2 of 2

Thread: Unable to edit after validation of fields in the Lineedits of the dialog box

  1. #1
    Join Date
    Sep 2015

    Default Unable to edit after validation of fields in the Lineedits of the dialog box

    The following is the code snippet.
    validateFields() is the function that does the work of validations and returns the appropriate int value depending upon the validation, based on which one either sets an alert or appends the data. However, the problem I face is that I am unable to continue editing data on the dialog box after the edit message is displayed.

    Ex:- The user first enters all the fields. Upon clicking on Ok, the validator checks all the fields, In case the name doesn't meet the criteria, it shows an Alert and upon closing it the dialog remains with the original values that were entered. However I am unable to edit the values in the lineedits and continue making changes in the dialog. Any help will be welcome.

    Qt Code:
    1. NewContactDialog d;
    2. int r_val= d.exec();
    3. int field_val=d.validateFields();
    4. if(r_val==1){
    6. switch(field_val){
    7. case 1:
    8. d.setName();
    9. d.appendData();
    10. break;
    11. case 2:
    12. QMessageBox::information(this,"Alert","Please enter only characters [a-z][A-Z] for the Name field.",QMessageBox::Ok);
    13. d.exec();
    14. break;
    16. default:
    17. d.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Unable to edit after validation of fields in the Lineedits of the dialog box

    My suggestion would be to do the validation in the dialog's accept() slot.
    This way you don't have to run the dialog again, it will just stay open.


Similar Threads

  1. Replies: 2
    Last Post: 4th April 2013, 06:36
  2. Empty Line Edit Validation
    By abgokbayrak in forum Newbie
    Replies: 1
    Last Post: 23rd October 2011, 05:44
  3. Replies: 2
    Last Post: 2nd May 2011, 06:33
  4. Adding validation to a QListView's edit mode
    By MattT in forum Qt Programming
    Replies: 10
    Last Post: 1st August 2010, 01:53

Tags for this Thread


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.