How to have atleast more than four digits/Characters
-
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,
-
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
-
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/)
-
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!
-
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,