Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to have atleast more than four digits/Characters

    Mobile and Embedded
    2
    7
    1929
    Loading More Posts
    • 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
      StarRocks last edited by

      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 Reply Quote 0
      • G
        goblincoding last edited by

        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 Reply Quote 0
        • S
          StarRocks last edited by

          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 Reply Quote 0
          • G
            goblincoding last edited by

            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 Reply Quote 0
            • S
              StarRocks last edited by

              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 Reply Quote 0
              • G
                goblincoding last edited by

                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 Reply Quote 0
                • S
                  StarRocks last edited by

                  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 Reply Quote 0
                  • First post
                    Last post