[Qt-interest] setValidator not working on QLineEdit..??
Gan Xiebin
gan.xiebin at gmail.com
Tue Jun 23 10:30:16 CEST 2009
Hello,
There is a method to set a validator to a QLineEdit,
void QLineEdit::setValidator(const QValidator *v)
I use this method on QLineEdit to get the input ( IP address ),
but the line edit allows *any value* outside this range.
like "999.999.999.999" :-(
============================
// myDlg.h
class myDlg : public QDialog
{
public:
myDlg(QWidget *parent = 0);
private:
QLabel *ipLabel;
QLineEdit *ipLineEdit;
};
// myDlg.cpp
myDlg::myDlg(QWidget *parent) : QDialog( parent )
{
QRegExp
rx("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
ipLabel = new QLabel(tr("IP Address:"));
ipLineEdit = new QLineEdit;
ipLabel->setBuddy(ipLineEdit);
QValidator *validator = new QRegExpValidator(rx, this);
ipLineEdit->setValidator(validator);
ipLineEdit->setInputMask("000.000.000.000;");
}
===================================
Did I missing something?
Thanks,
Bin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090623/0686da73/attachment.html
More information about the Qt-interest-old
mailing list