Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

[Solved]Limit number of characters in QTextEdit

$
0
0
Well, I need to limit the number of characters in a QTextEdit. I found something that says to rewrite the keyPressEvent and enter a event filter. I was thinking of something like if(textEdit->document()->characterCount() >= maxLen) { limit the editing only for delete, up, down, etc. } else { normal editing } The problem is that I am not sure on how to implement this. On the else I just copy from the normal keyPressEvent. I know I can use QLineEdit but I need a multiline text editor. Also it will only contain plain text (no html subset).

Viewing all articles
Browse latest Browse all 18427

Trending Articles