Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to limit the number of characters in QPlainTextEdit?
Forum Updated to NodeBB v4.3 + New Features

How to limit the number of characters in QPlainTextEdit?

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _jao_victor_
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    1
    • D Offline
      D Offline
      DoubleFelix
      wrote on last edited by
      #2

      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)

      1 Reply Last reply
      4
      • _ _jao_victor_

        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?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @_jao_victor_
        Additional to @DoubleFelix's find, untested but I assume you could also limit the number characters by placing a suitable QValidator on the QPlainTextEdit. If that works, you shouldn't have to deal with key press events.

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved