Search code examples
regexqtvalidationqlineedit

How to restrict the expression in QLineEdit


I need a QLineEdit which must represent a range. F.E. (1,2] , and for this representation I want to set a validation checker for user not to write other symbols. In this case I have char + int + char + int + char as shown in example below. Does Qt have any feature to handle this? Thanks in advance.


Solution

  • QRegExp expr("^[[,(]{1,1}(0|[1-9]{1,1}[0-9]{0,9})[,]{1,1}(0|[1-9]{1,1}[0-9]{0,9})[],)]{1,1}$");
    

    This is what I wanted! I must allow more then one leading 0-s.