I think you need to make it this way: Code: QRegExp regexer("^\\#[0-9a-fA-F]{6,6}$"); ^ = from the start of the string (.. your characters ..) $ = until the end of the string
QRegExp regexer("^\\#[0-9a-fA-F]{6,6}$");
... The match is made against the entire string, e.g. if the regexp is [A-Fa-f0-9]+ it will be treated as ^[A-Fa-f0-9]+$.