Results 1 to 5 of 5

Thread: Setting Max Limit in Text Box

  1. #1
    Join Date
    Feb 2007
    Posts
    22
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Setting Max Limit in Text Box

    Hi,

    Can anyone please tell me how to set the maximum limit in textEdit boxes.

    Suppose I have a textEdit box which should accept only 2 characters or numbers.

    How to do it.

    With Kind
    Regards
    Kenny

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Setting Max Limit in Text Box

    Use a QLineEdit, and use QLineEdit::setMaxLength() to restrict the length of the contents.

    Edit: Furthermore, you can also use QLineEdit::inputMask property to restrict the content to some specific characters.
    Last edited by jpn; 28th February 2007 at 10:38. Reason: updated contents
    J-P Nurmi

  3. #3
    Join Date
    Feb 2007
    Posts
    22
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Setting Max Limit in Text Box

    Will this work for TextEdit;

    I havnt seen a property for Text Edit like this.

  4. #4
    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: Setting Max Limit in Text Box

    Why do you need a QTextEdit if you want to allow only two characters?

  5. #5
    Join Date
    Mar 2007
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Setting Max Limit in Text Box

    Quote Originally Posted by wysota View Post
    Why do you need a QTextEdit if you want to allow only two characters?
    I've the same question: I would like to limit the user input to, say, 4 lines of 80 characters. How to do this with a QTextEdit?

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Replies: 2
    Last Post: 23rd July 2012, 08:42
  3. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  4. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30
  5. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25

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.