Results 1 to 2 of 2

Thread: Set maximum input length in spinbox?

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Set maximum input length in spinbox?

    I have a Spinbox. Its maximum value is 99, although this doesn't avoids the user to input e.g.
    000000000000000000000000000000000000099
    this is quite weird :/
    How can i change the max input length of the spinbox? I found nothing from the properties menu
    thx for any answer!
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  2. #2
    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: Set maximum input length in spinbox?

    Quote Originally Posted by hakermania View Post
    I have a Spinbox. Its maximum value is 99, although this doesn't avoids the user to input e.g.
    000000000000000000000000000000000000099
    this is quite weird :/
    I'd say 0000000000000000099 is exactly 99 which is in the bounds specified by the minimum and maximum value allowed.

    How can i change the max input length of the spinbox? I found nothing from the properties menu
    thx for any answer!
    Reimplement validate() and/or fixup(). The former should be quite easy:
    Qt Code:
    1. QValidator::State MySpinBox::validate( QString &text, int pos) const {
    2. if(text.size()>2) return QValidator::Invalid;
    3. return QSpinBox::validate(text, pos);
    4. }
    To copy to clipboard, switch view to plain text mode 
    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.


Similar Threads

  1. QTextEdit - how to limit maximum length?
    By Henrikas[MI] in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2010, 20:38
  2. Is it possible to set a maximum length for QTextEdit ???
    By vairamuthu.g in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2010, 05:17
  3. Set Maximum Length of QTextEdit
    By moh.gup@gmail.com in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2010, 08:27
  4. Replies: 33
    Last Post: 10th June 2010, 16:51
  5. Maximum input length for QTextEdit or QPlainTextEdit ??
    By b_ginner in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2009, 20:57

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.