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 Also, you might consider this: Code: ui->line_edit_font1->setValidator(new QRegExpValidator(regexer, ui->line_edit_font1); I think the parent is wrong, you have it on "this", which is the whole class, I think you need to put it on the QLineEdits specifically. Edit: this way, you don't have to make "actualvalidator".
QRegExp regexer("^\\#[0-9a-fA-F]{6,6}$");
ui->line_edit_font1->setValidator(new QRegExpValidator(regexer, ui->line_edit_font1);