Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. more flexible SetMaskInput
Forum Updated to NodeBB v4.3 + New Features

more flexible SetMaskInput

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 579 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.
  • N Offline
    N Offline
    NinaWeber
    wrote on last edited by
    #1

    Hello,
    I would like to make a mask input in a line edit for an IP address. Most often I find the suggestion
    mylineEdit->setInputMask("000.000.000.000");
    But if I enter an IP address like 192.168.0.100 it would look like 192.168.0 .100 with two spaces in it.
    Is there a way to avoid that?
    I would appreciate any help! Thank you

    raven-worxR 1 Reply Last reply
    0
    • N NinaWeber

      Hello,
      I would like to make a mask input in a line edit for an IP address. Most often I find the suggestion
      mylineEdit->setInputMask("000.000.000.000");
      But if I enter an IP address like 192.168.0.100 it would look like 192.168.0 .100 with two spaces in it.
      Is there a way to avoid that?
      I would appreciate any help! Thank you

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @NinaWeber
      use QRegExpValidator (Qt4) or QRegularExpressionValidator (Qt5)
      with the following regexp:

      "25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
      

      or less accurate:

      "(?:[0-9]{1,3}\.){3}[0-9]{1,3}"
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1

      • Login

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