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 can i have a textEdit which just receive number?
QtWS25 Last Chance

How can i have a textEdit which just receive number?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 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.
  • A Offline
    A Offline
    Armin
    wrote on last edited by
    #1

    Hi
    How can i have a textEdit which just receive number?
    What member of QTextEdit class i should use ?
    if user write anything except numbers , i want to make a warning.
    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you really need a QTextEdit or would a QSpinBox be enough ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Armin
        wrote on last edited by
        #3

        Thanks @SGaist
        I need QTextEdit because i have a textEdit and user want to write a number , if user write alphabet i want to which textedit drop that.
        sorry if my english is bad.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That I understood, my question was rather: do you need any feature of QTextEdit for your use case ? If not then, using a QSpinBox would make more sense.

          Otherwise you'll have to implement a solution like described here.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • A Offline
            A Offline
            Armin
            wrote on last edited by
            #5

            Thanks @SGaist
            I saw QSpingbox , I can enter 2 numbers and no more.
            Why? can i enter 7 or 8 number ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              It's up to you to fix the limit of what can be entered in your QSpinBox. Take a look at setMinimum and setMaximum

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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