I have written a method that validate characters in the lineEdit:
def is_validate(self):
regex = QtCore.QRegExp("[a-z-A-Z_]+")
txtDepartment_validator = QtGui.QRegExpValidator(regex, self.txtDepartment)
self.txtDepartment.setValidator(txtDepartment_validator)
return True
and use it another method like below
def control_information(self):
if(self.is_validate()):
//Database operations
else:
QtGui.QMessageBox.text("Please enter valid characters")
But when I enter numbers or special character it accepts and save to database. What is wrong?