QLineEdit for editing hexadecimal and decimal numbers
I would like to use a QLineEdit control to edit or decimal (0..255) or hexadecimal (0x00 .. 0xFF) numbers. The user should be able to enter the number in one or the other format, and the decimal number has to be limited to 255.
Can this all be done by using only a QRegExp for the validator ?
Does anyone has an idea how the validator would then look like ?
Re: QLineEdit for editing hexadecimal and decimal numbers
something like
should work
Re: QLineEdit for editing hexadecimal and decimal numbers
This will NOT work correctly!
"\\d{,3}" accepts digits in the range 0-999.
Try this:
Code:
QRegExp re
("^\\b(0x([0-9A-F]{1,2}))|(([0-2])([0-5])?([0-5])?)\\b$");