I'm trying to validate the input of a QLineEdit (here lineEdit_new_nickname) with a regular expression, the problem is it seem to be no validator at all, even if ->validator() returns the right QRegExpValidator. I have no idea what the problem could be. The code:
setupUi(this);
lastPreferredNickname = NULL;
//TODO: Actually we should set the "11" part after connecting and getting RAW 005 to NICKLEN-1
//QRegExp nick_regexp("[a-zA-Z][a-zA-Z0-9[]\\\\`^{}-]{0,11}");
lineEdit_new_nickname->setValidator(&nick_validator);
dbg() << "validator:" << lineEdit_new_nickname->validator();
dbg() << "connecting toolButton_add_nickname to listWidget_nicknames remove_nickname" <<
dbg() << "connecting listWidget_nicknames::widgetsReordered() to this->nicknamesReordered" <<
connect(listWidget_nicknames,
SIGNAL(widgetsReordered
(QDropEvent*)),
this,
SLOT(nicknamesReordered
(QDropEvent*)));
/**/
}
IRCSettings::IRCSettings( QWidget *parent) : QWidget(parent) {
setupUi(this);
lastPreferredNickname = NULL;
//TODO: Actually we should set the "11" part after connecting and getting RAW 005 to NICKLEN-1
//QRegExp nick_regexp("[a-zA-Z][a-zA-Z0-9[]\\\\`^{}-]{0,11}");
QRegExpValidator nick_validator(QRegExp("[a-zA-Z][a-zA-Z0-9[]\\\\`^{}-]{0,11}"),this);
lineEdit_new_nickname->setValidator(&nick_validator);
dbg() << "validator:" << lineEdit_new_nickname->validator();
dbg() << "connecting toolButton_add_nickname to listWidget_nicknames remove_nickname" <<
connect(listWidget_nicknames,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(remove_preferred_nickname(QListWidgetItem*)));
dbg() << "connecting listWidget_nicknames::widgetsReordered() to this->nicknamesReordered" <<
connect(listWidget_nicknames,SIGNAL(widgetsReordered(QDropEvent*)),this,SLOT(nicknamesReordered(QDropEvent*)));
/**/
}
To copy to clipboard, switch view to plain text mode
Edit: it's not working even with the regexp ".", so the mistake is not there
Bookmarks