PDA

View Full Version : QTextEdit: prevent the insertion of some character.



bred
18th October 2010, 13:25
It's possible to prevent the insertion of some specific character in the QTextEdit widget?

high_flyer
18th October 2010, 13:39
have a look at QValidator

Lykurg
18th October 2010, 13:54
As far as I know QValidator is best used with a line edit. For a text edit you have to catch the key press events and filter there. An easy solution is not available. Only if you dealing with small text you can use the text changed signal and perform replace/remove instructions on the whole text.

high_flyer
18th October 2010, 15:13
Sorry, for some reason my brain interpreted QTextEdit as QLineEdit.