16,817
社区成员




class IPLineEdit : public QWidget
{
Q_OBJECT
public:
IPLineEdit(QWidget *parent = 0);
private:
QLineEdit *ipLineEdit;
QLabel *ipLabel;
QHBoxLayout *layout;
QRegExp *ipRegExp;
QRegExpValidator *ipRegExpValidator;
};
IPLineEdit::IPLineEdit(QWidget *parent)
{
ipLabel = new QLabel(tr("IP Address:"));
ipLineEdit = new QLineEdit;
ipLabel->setBuddy(ipLineEdit);
ipRegExp = new QRegExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-4]|[01]?\\d\\d?)");
ipRegExpValidator = new QRegExpValidator(ipRegExp, this);
ipLineEdit->setValidator(ipRegExpValidator);
ipLineEdit->setInputMask("000.000.000.000;");
layout = new QHBoxLayout;
layout->addWidget(ipLabel);
layout->addWidget(ipLineEdit);
setLayout(layout);
}