Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to have atleast more than four digits/Characters
Forum Updated to NodeBB v4.3 + New Features

How to have atleast more than four digits/Characters

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 2 Posters 2.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.
  • S Offline
    S Offline
    StarRocks
    wrote on last edited by
    #1

    Dear Forums,

                         I am new to Qt....I have a doubt how can i allow more than four digits/Character in a QLineEdit i have done in restricting the number of characters/digits by using *setMaxlength()* but im not knowing about the issue i have raised.......Please provide me with an solution.........
    

    Regards,

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

      If I understand you correctly, you may want to consider using regular expressions and "QRegExp":https://qt-project.org/doc/qt-4.8/qregexp.html

      http://www.goblincoding.com

      1 Reply Last reply
      0
      • S Offline
        S Offline
        StarRocks
        wrote on last edited by
        #3

        Dear goblincoding,

                               Thanks for the reply.......Actually i have gone through those but dint find any solution.can you give me any syntax......Any solution would be appreciable.........Thanks in Advance.........
        

        Regards,

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goblincoding
          wrote on last edited by
          #4

          I believe the following regex should do what you want (allow a minimum of 4 word characters to be entered into your line edit):

          \w{4,}

          An example of how you can put it all together

          @
          QRegExp regex("\w{4,}"); //escape the ""
          QRegExpValidator *validator = new QRegExpValidator(regex, this);
          yourLineEdit->setValidator(validator);
          @

          Please test this to make sure it does what you want.

          (a useful site for testing regular expressions is "Rubular":http://rubular.com/)

          http://www.goblincoding.com

          1 Reply Last reply
          0
          • S Offline
            S Offline
            StarRocks
            wrote on last edited by
            #5

            Dear goblincoding,

                                        Thanks for the reply…….Actually i want this validation in the button i.e when i click the insert/submit button this action should be performed……Any solution would be appreciable………Thanks in Advance………
            

            Regards,

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goblincoding
              wrote on last edited by
              #6

              You will need to start studying Qt if you are planning on using the framework, there simply is no other way.

              I suggest you start by reading "how to Learn Qt":https://qt-project.org/doc/qt-4.8/how-to-learn-qt.html

              Pay close attention to the "Meta-Object System":https://qt-project.org/doc/qt-4.8/metaobjects.html and "Signals and Slots":https://qt-project.org/doc/qt-4.8/signalsandslots.html#signals-and-slots

              Remember that the "Qt Documentation":https://qt-project.org/doc/ is your friend :)

              Good luck!

              http://www.goblincoding.com

              1 Reply Last reply
              0
              • S Offline
                S Offline
                StarRocks
                wrote on last edited by
                #7

                Dear goblincoding,

                                          Thanks for the reply..........I got the solution for the above query i have asked for and i have written the code in the button event as if(objectnameofthefield.length()<4) and it worked for me...Thanks in advance..........Hope this is the right way i have worked i guess.......Any solution would be appreciable......
                

                Regards,

                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