diff --git a/src/frontend/netdetails/creatnetpage.cpp b/src/frontend/netdetails/creatnetpage.cpp index bd50cc20..beeaa366 100644 --- a/src/frontend/netdetails/creatnetpage.cpp +++ b/src/frontend/netdetails/creatnetpage.cpp @@ -33,7 +33,6 @@ CreatNetPage::CreatNetPage(QWidget *parent):QFrame(parent) void CreatNetPage::initUI() { connNameEdit = new LineEdit(this); - connNameEdit->setMaxLength(MAX_NAME_LENGTH); ipv4ConfigCombox = new QComboBox(this); ipv4addressEdit = new LineEdit(this); netMaskEdit = new LineEdit(this); @@ -109,6 +108,10 @@ void CreatNetPage::initUI() ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)" ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动" + QRegExp nameRx("^.{0,32}$"); + QValidator *validator = new QRegExpValidator(nameRx, this); + + connNameEdit->setValidator(validator); ipv4addressEdit->setValidator(new QRegExpValidator(rx, this)); gateWayEdit->setValidator(new QRegExpValidator(rx, this)); netMaskEdit->setValidator(new QRegExpValidator(rx, this)); diff --git a/src/frontend/netdetails/detailpage.cpp b/src/frontend/netdetails/detailpage.cpp index fb95803a..46a1c85c 100644 --- a/src/frontend/netdetails/detailpage.cpp +++ b/src/frontend/netdetails/detailpage.cpp @@ -245,7 +245,10 @@ void DetailPage::initUI() { m_SSIDEdit->setAlignment(Qt::AlignRight); m_SSIDEdit->setStyleSheet("border-top:0px solid;border-bottom:1px solid;border-left:0px solid;border-right: 0px solid;background:transparent"); m_SSIDEdit->setPlaceholderText(tr("Please input SSID:")); - m_SSIDEdit->setMaxLength(MAX_NAME_LENGTH); + QRegExp nameRx("^.{0,32}$"); + QValidator *validator = new QRegExpValidator(nameRx, this); + + m_SSIDEdit->setValidator(validator); m_ssidWidget = new DetailWidget(qobject_cast(m_SSIDEdit), m_listWidget); } diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp index d5792bc6..16cc963d 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.cpp +++ b/src/frontend/netdetails/joinhiddenwifipage.cpp @@ -147,7 +147,9 @@ void JoinHiddenWiFiPage::initUI() m_cancelBtn->setText(tr("Cancel")); m_joinBtn->setText(tr("Join")); - m_nameEdit->setMaxLength(MAX_NAME_LENGTH); + QRegExp nameRx("^.{0,32}$"); + QValidator *validator = new QRegExpValidator(nameRx, this); + m_nameEdit->setValidator(validator); m_nameEdit->setPlaceholderText(tr("Required")); //必填 this->setWindowTitle(tr("Find and Join WLAN"));