重新上传

This commit is contained in:
feiyangqingyun
2021-01-16 12:41:38 +08:00
parent 9cf0de0f8d
commit e8195be0e3
149 changed files with 1545 additions and 6219 deletions

View File

@@ -4,10 +4,12 @@
#include "qlabel.h"
#include "qlineedit.h"
#include "qboxlayout.h"
#include "qregexp.h"
#include "qvalidator.h"
#include "qevent.h"
#include "qdebug.h"
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
#include "qregexp.h"
#endif
IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
{
@@ -53,6 +55,7 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
txtIP4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(txtIP4, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
//设置IP地址校验过滤
QRegExp regExp("(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})");
QRegExpValidator *validator = new QRegExpValidator(regExp, this);
@@ -60,6 +63,7 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
txtIP2->setValidator(validator);
txtIP3->setValidator(validator);
txtIP4->setValidator(validator);
#endif
//绑定事件过滤器,识别键盘按下
txtIP1->installEventFilter(this);
@@ -79,13 +83,13 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
frame->setStyleSheet(qss.join(""));
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
verticalLayout->setMargin(0);
verticalLayout->setContentsMargins(0, 0, 0, 0);
verticalLayout->setSpacing(0);
verticalLayout->addWidget(frame);
//将控件按照横向布局排列
QHBoxLayout *layout = new QHBoxLayout(frame);
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(txtIP1);
layout->addWidget(labDot1);
@@ -153,11 +157,13 @@ QSize IPAddress::minimumSizeHint() const
void IPAddress::setIP(const QString &ip)
{
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
//先检测IP地址是否合法
QRegExp regExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
if (!regExp.exactMatch(ip)) {
return;
}
#endif
if (this->ip != ip) {
this->ip = ip;

View File

@@ -3,12 +3,12 @@
/**
* IP地址输入框控件 作者:feiyangqingyun(QQ:517216493) 2017-8-11
* 1:可设置IP地址,自动填入框
* 2:可清空IP地址
* 3:支持按下小圆点自动切换
* 4:支持退格键自动切换
* 5:支持IP地址过滤
* 6:可设置背景色/边框颜色/边框圆角角度
* 1. 可设置IP地址,自动填入框
* 2. 可清空IP地址
* 3. 支持按下小圆点自动切换
* 4. 支持退格键自动切换
* 5. 支持IP地址过滤
* 6. 可设置背景色/边框颜色/边框圆角角度
*/
#include <QWidget>
@@ -17,13 +17,7 @@ class QLabel;
class QLineEdit;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT IPAddress : public QWidget
class Q_DECL_EXPORT IPAddress : public QWidget
#else
class IPAddress : public QWidget
#endif