I wrote a mobile phone QRegExp validator, added it to LineEdit. In addition, I added a mask. (After several mistakes, I realized that the mask must be added after the validator, otherwise nothing fits) Validator (QRegExp):
QRegularExpression numberRegex ("^\\+\\d{1,1}\\(\\d{1,3}\\)\\d{1,3}\\-\\d{1,2}\\-\\d{1,2}$");
QRegularExpressionValidator *numberValidator = new QRegularExpressionValidator (numberRegex);
code for adding a mask and the validator itself for QLineEdit:
ui->lineEdit_4->setValidator(numberValidator);
ui->lineEdit_4->setInputMask("+7(000)000-00-000");
Everything works correctly, the number is entered in the correct form, but there is a problem: When writing a number, I can erase by pressing (backspace), but after I enter the last character, I can't erase anymore.
UPD:If I make a mask with an additional "0" at the end, then everything is erased, but it no longer fits the mask I need. TOTAL: if the mask and the validator "coincide", then at the end of writing it is impossible to erase UPD2: if i click ALT+Shift last 2 symbols will be erased anyway