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, more than one in a one QLineEdit
Forum Updated to NodeBB v4.3 + New Features

QValidator, more than one in a one QLineEdit

Scheduled Pinned Locked Moved General and Desktop
qlineeditqvalidator
7 Posts 5 Posters 2.6k Views 3 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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

    Hi everybody. I need to accept a string formatted like this:

    E12:34,2a

    where

    • the first charter (E) can be E or U
    • a time value (12:34)
    • an alphanumeric value (2a)

    Is possible or have I to split in 3 QLineEdit objects?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrahamL
      wrote on last edited by
      #2

      Hi
      you might want to take a look at
      http://doc.qt.io/qt-5/qregularexpressionvalidator.html

      HTH

      1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        My rule is
        ([I,O]| )([0-2]| )([0-9]| ):([0-5]| )([0-9]| )
        to have for example
        I08:00 or O18:30
        Is there a way to have it in uppercase?
        08:00 and 18:30 are times fields. Is there a way to force value from 00 to 23? Now I can write 25 for example.

        Regards.

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          ([0-1][0-9]|2[0-3])for the 00 to 23

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alex_malyu
            wrote on last edited by
            #5

            Another option may be subclassing validator.

            1 Reply Last reply
            0
            • mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #6

              Perfetc, and to have uppercase? I need only I or O and not i o.
              Is there a way to have replace mode instead of insert mode in the qlineedit? I need to rewrite without select or delete.

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              K 1 Reply Last reply
              0
              • mrdebugM mrdebug

                Perfetc, and to have uppercase? I need only I or O and not i o.
                Is there a way to have replace mode instead of insert mode in the qlineedit? I need to rewrite without select or delete.

                K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                @mrdebug
                If you are using only uppercase letters in QRegExp you should be fine. E.g. "[IO]{1,1}" shall match only an uppercase 'I' or an uppercase 'O'.

                Vote the answer(s) that helped you to solve your issue(s)

                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