PDA

View Full Version : Unable to edit after validation of fields in the Lineedits of the dialog box



newtoQ_s
20th October 2015, 07:26
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.


NewContactDialog d;
int r_val= d.exec();
int field_val=d.validateFields();
if(r_val==1){

switch(field_val){
case 1:
d.setName();
d.appendData();
break;
case 2:
QMessageBox::information(this,"Alert","Please enter only characters [a-z][A-Z] for the Name field.",QMessageBox::Ok);
d.exec();
break;

default:
d.exec();
}

anda_skoa
21st October 2015, 18:43
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.

Cheers,
_