2012-04-16 97 views
3

我试图为IP地址创建一个TextInput,我需要控制范围(0-255)。使用TextInput的IP地址掩码

我使用了regExp验证程序,并且还使用的inputMask,但取消了验证程序。

如何使用输入掩码创建IP验证器?

TextInput 
{ 
    id: myLineEdit 
    anchors.fill: parent 
    cursorVisible: true 
    focus: true 

    validator:RegExpValidator 
    { 
    regExp:/^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/ 
    } 

    inputMask: "000.000.000.000;0" 
} 
+0

那么ipv6呢? – mensi 2012-04-16 20:36:38

+0

这在qml中没有用 – user1335880 2012-04-17 06:24:48

+0

我试过你的代码,并且所有东西似乎都可以在QtQuick 1.1中正常工作。 – alexisdm 2012-04-18 16:06:53

回答

0

跳过输入掩码。

而你应该为IPv4和IPv6定义不同的组件。