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. QTextedit to allow only numbers ...

QTextedit to allow only numbers ...

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 12.5k 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.
  • K Offline
    K Offline
    karti gesar
    wrote on last edited by
    #1

    hi all...how to all only number in qtextedit

    1 Reply Last reply
    0
    • K Offline
      K Offline
      karti gesar
      wrote on last edited by
      #2

      i have tried in lineedit ..with the help of QRegularExpression but it is not possible in textedit

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vicky Sharma
        wrote on last edited by
        #3

        @karti-gesar
        Have you used proper regular expression only for no.?
        and for which purpose you want only no. like for mobile no. for getting percentage ect?
        or you can use reqexp.setPattern("^[0-9\ \(\)\+]$");

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Max13
          wrote on last edited by
          #4

          If you really need a QTextEdit which is a widget made to hold a document (multiline text or rich-text) but accepting only numbers, it's not made for that, so I think you will have to hack a little bit.

          Try to connect a slot to QTextEdit::textChanged() signal, you retrieve the text and play with it.

          But, if you only need one line input from your user, for instance phone number, you can use QLineEdit on which you can enforce an input mask using QLineEdit::setInputMask()

          We all have started by asking questions. Then after some time, we can begin answering them.

          1 Reply Last reply
          1
          • K Offline
            K Offline
            karti gesar
            wrote on last edited by
            #5

            thanks ji...for your comment....i used lineedit itself

            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