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. QValidator for floating point with optional % sign at the end
Forum Updated to NodeBB v4.3 + New Features

QValidator for floating point with optional % sign at the end

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

    I've got an entry field which is effectively for a double, but should allow the use of a % sign at the end. IOW it should allow:

    1234.56

    or

    99.95%

    If it has a percent sign the range should be 0-99.99.

    If not in UK/US then allow , as decimal seperator.

    QDoubleValidator covers all except the use of %ages

    Is it possible to write a regex that allows arbitrary length b4 decimal part and two decimal places, OR two digits before decimal part and two decimal places followed by %?

    You may gather correctly that I'm not a heavy user of RegExs

    D.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Don't use a regexp but analyze your entered string 'manually' by trying to convert it do a double and remove the percent sign before if it's at the end.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

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