Results 1 to 9 of 9

Thread: Display more than four digits/characters

  1. #1
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Display more than four digits/characters

    Dear Forums,


    Im a newbie in QT.....I have a doubt regarding QlineEdit actually i need to have max of 10numbers if i enter 5 numbers it should raise me an error saying please enter max of 10 numbers........I have restricted to 10 that i have done but not knowing how to restrict the one i have asked for........Thanks in Advance.........


    Regards,

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Display more than four digits/characters

    Your requirement is not consistent, so perhaps you should attend to that first. You want at most 10 digits and say that 5 digits is not acceptable with a message indicating the user should enter a maximum of 10 digits. As far as the user is concerned, they have entered a maximum of 10, that is than or equal to 10 digits.

    You can use an input mask or QValidator or one if its subclasses to restrict what is acceptable input for a QLineEdit.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display more than four digits/characters

    Maybe it's "10" in binary
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Display more than four digits/characters

    Dear Chris,

    Thanks for the reply......I want a validation in the button event so that when i click the button it should raise me an error saying please enter the field greater than four digits/characters......Any reply would be appreciable.......Thanks in Advance.......

    Regards,

  5. #5
    Join Date
    Dec 2012
    Posts
    90
    Thanks
    5
    Thanked 20 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Display more than four digits/characters

    So you should do as you said, it's not rocket science .)

    In your button event handler check lineEdit->text ().length () > 4.
    Don't forget to exclude/replace spaces if needed and if you haven't filtered them in input mask.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Display more than four digits/characters

    Quote Originally Posted by StarRocks View Post
    Thanks for the reply......I want a validation in the button event so that when i click the button it should raise me an error saying please enter the field greater than four digits/characters......Any reply would be appreciable.......Thanks in Advance.......
    And I want a pony... but I have to work for the horse feed. Show the code you have used to try to do these size checks when a button is clicked.

    BTW, your requirements are now:
    • Maximum of 10 characters (from first post)
    • More than 4 characters (from second post)
    • But not 5 characters ??? (from first post)


    Also consider that another solution may be to stop the user from clicking the button unless their input is already valid.

  7. #7
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: Display more than four digits/characters

    Dear Lanz,


    Thanks for the reply.......Its working fine for me when i give in the button event but a small correction in the syntax
    Qt Code:
    1. its not
    2. lineEdit->text ().length () > 4
    3. rather its
    4. lineEdit->text ().length () < 4
    To copy to clipboard, switch view to plain text mode 

    thats the only difference.......Thanks in Advance.....Hope i guess thats the better way to code......Any ideas would be appreciable.....


    Regards,

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Display more than four digits/characters

    So now 4 characters is acceptable.

  9. The following user says thank you to ChrisW67 for this useful post:

    StarRocks (2nd February 2013)

  10. #9
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: Display more than four digits/characters

    Dear Chris,


    Thanks for the reply......It Really worked fine for me............Thanks in Advance


    Regards,

Similar Threads

  1. Unable to display selected unicode characters
    By nickw2066 in forum Qt Programming
    Replies: 0
    Last Post: 19th November 2012, 11:20
  2. QTextEdit not display new line characters
    By aruval3 in forum Qt Programming
    Replies: 2
    Last Post: 30th November 2011, 05:46
  3. Chinese Language display in Nokia showing " ????? " characters
    By behlkush in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 25th April 2011, 10:23
  4. Problem with chinese and japanese characters display
    By manojmka in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th February 2010, 06:09
  5. Problem with korean characters display
    By giriprasad in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th September 2009, 09:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.