Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TextInput with mask for IP
Forum Updated to NodeBB v4.3 + New Features

TextInput with mask for IP

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 7.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goli
    wrote on last edited by
    #1

    I am trying to create a TextInput for IP Address, and i need to control the ranges(0-255).

    this is what tried:

    @
    TextInput
    {
    id: myIpEdit
    anchors.fill: parent
    cursorVisible: true
    focus: true

            validator: IntValidator{bottom: 0; top: 255;}
    
            inputMask: "000.000.000.000;0"
            
            selectByMouse: true
    

    }
    @

    but it did'nt work, so i tried to use regular expration:
    @
    TextInput
    {
    id: myIpEdit
    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"
            
            selectByMouse: true
    

    }
    @

    This enable to control the range(upper limit: 255), but also prevent inserting of zeros to the text.

    how can I create this IP TextInput correctly?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jediengineer
      wrote on last edited by
      #2

      I believe the input mask should be:
      @
      inputMask: "000.000.000.000;_"
      @

      see this documentation: "InputMask":http://qt-project.org/doc/qt-5/qlineedit.html#inputMask-prop

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jediengineer
        wrote on last edited by
        #3

        I take that back, I misread the doc... that's just the character holder.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved