Solved How to limit the number of characters in QPlainTextEdit?
-
I have a QPlainTextEdit and I want to limit the number of characters that the user can enter to 200. I took a quick look at the documentation and didn't find anything to help me. How do I set a character limit in QPlainTextEdit?
-
I found this post that you could try:
https://wiki.qt.io/Qt_project_org_faq#How_can_I_get.2Fset_the_max_length_of_a_QTextEdit_.3F (Section 12) -
I found this post that you could try:
https://wiki.qt.io/Qt_project_org_faq#How_can_I_get.2Fset_the_max_length_of_a_QTextEdit_.3F (Section 12) -
@_jao_victor_
Additional to @DoubleFelix's find, untested but I assume you could also limit the number characters by placing a suitable QValidator on theQPlainTextEdit
. If that works, you shouldn't have to deal with key press events.