QRegExp assigning a value based on a condition
-
hi, I want to create my own dateEdit using QLineEdit. So far I've created a QRegExp. It's getting close to what I want, but I haven't quite caught it yet. I want the program to put a period automatically after the Day and Month parts are entered. How can I update this? Here is the current code ;
QRegularExpression rx4("[0-9]{0,2}[.][0-9]{0,2}[.][0-9]{0,4}"); QValidator *validator = new QRegularExpressionValidator(rx5, this); ui->lineEdit->setValidator(validator);
-
@Nevez
That is a quite different question from your original. You could do this with regular expressions, but it's not ideal. I think https://stackoverflow.com/questions/53611816/input-mask-and-validator-for-date-in-qlineedit?rq=1 does something like this. Better is integer validators, and for what you want custom code in the validation.Why you are wanting to reinvent the wheel for "my own dateEdit using QLineEdit" I do not know when Qt has a
QDateEdit
widget, optionally with a popup calender for the user. The whole job is done for you, including the parsing and returning of the date.