Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to apply QIntValidator for QTextEdit
Qt 6.11 is out! See what's new in the release blog

How to apply QIntValidator for QTextEdit

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 5.7k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    neel2818
    wrote on last edited by
    #1

    Hi All,

    Is there any way to apply integer and real validator to QTextEdit widget ?
    I have tried but i am not able to apply the QIntValidator to QTextEdit. For that i have to use QLineEdit.

    Is there anyway i can apply integer and real validator in QTextEdit ?

    Thanks,
    Neel

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      What's wrong or unclear with the "example of use" in the [[Doc:QIntValidator]] docs?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • N Offline
        N Offline
        neel2818
        wrote on last edited by
        #3

        This example validator is applied on QLineEdit that is applicable. But I am not able to apply validator on QTextEdit.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          broadpeak
          wrote on last edited by
          #4

          I could only solve in this way:
          QString QTextEdit::toPlainText();
          And after this I could use the validator.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Ah, sorry, I misread and confused TEXT edit with LINE edit.

            I don't get the use case, though. The text edit widget is designed for multi-line, probably rich, text, whereas an integer or real number is only one line and would best fit into a line edit...

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              I guess your problem is that QTextedit does not have a setValidator method.
              Why that is the case? Volker has given the answer. Multi-line may make it time consuming.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0

              • Login

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