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. How to pad QLineEdit with zeros for number-only entry?
Forum Updated to NodeBB v4.3 + New Features

How to pad QLineEdit with zeros for number-only entry?

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

    I am building a custom date edit using separate QLineEdit instances for month, day, year. I want to make it so each QLineEdit pads its current value with '0' (zero). I am using QIntValidator to validate the ranges.

    I have set the widget mask to for example 'DD' for the month box, but this doesn't pad a single-digit month with a zero.

    Anyone know how to do this?

    Thanks!

    https://alaskafamilysystems.com/

    jsulmJ 1 Reply Last reply
    0
    • P patrickkidd

      I am building a custom date edit using separate QLineEdit instances for month, day, year. I want to make it so each QLineEdit pads its current value with '0' (zero). I am using QIntValidator to validate the ranges.

      I have set the widget mask to for example 'DD' for the month box, but this doesn't pad a single-digit month with a zero.

      Anyone know how to do this?

      Thanks!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @patrickkidd said in How to pad QLineEdit with zeros for number-only entry?:

      QLineEdit

      Did you try "DD;\0" for inputMask as described here: http://doc.qt.io/qt-5/qlineedit.html#inputMask-prop

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      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