QML自定义IP地址输入框
更新:HHH   时间:2023-1-7


QML输入框同样能用正则表达式,在输入ip地址时使用正则来判断输入的正确性

    TextField {
    id: textfield_operation_ip1
    x: 492
    y: 120
    width: 269
    height: 61
    text: ""
    visible: true
    placeholderText: qsTr("请输入IP地址")
    font.pixelSize: 25
    focus:true
    validator: RegExpValidator{regExp:/(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/}

// style: textfied_style
}

返回系统运维教程...