PDA

View Full Version : Setting Max Limit in Text Box



kenny_isles
28th February 2007, 10:20
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

jpn
28th February 2007, 10:24
Use a QLineEdit, and use QLineEdit::setMaxLength() to restrict the length of the contents.

Edit: Furthermore, you can also use QLineEdit::inputMask (http://doc.trolltech.com/3.3/qlineedit.html#inputMask-prop) property to restrict the content to some specific characters.

kenny_isles
28th February 2007, 10:52
Will this work for TextEdit;

I havnt seen a property for Text Edit like this.

wysota
28th February 2007, 10:54
Why do you need a QTextEdit if you want to allow only two characters?

KoosKoets
15th August 2007, 08:40
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?