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. numeric digit test
Forum Updated to NodeBB v4.3 + New Features

numeric digit test

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 271 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.
  • H Offline
    H Offline
    Hayri
    wrote on last edited by
    #1

    hello

    The number entered in the line edit,
    what should I do to test that it is a number (for example : entered :1 , or , entered :5.7 , and so on) ,
    can you help me
    thanks.

    jsulmJ 1 Reply Last reply
    0
    • H Hayri

      hello

      The number entered in the line edit,
      what should I do to test that it is a number (for example : entered :1 , or , entered :5.7 , and so on) ,
      can you help me
      thanks.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Hayri You can use https://doc.qt.io/qt-6/qlineedit.html#setValidator
      But better:

      • For integer numbers you should use https://doc.qt.io/qt-5/qspinbox.html
      • For floating point numbers: https://doc.qt.io/qt-5/qdoublespinbox.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Hayri You can use https://doc.qt.io/qt-6/qlineedit.html#setValidator
        But better:

        • For integer numbers you should use https://doc.qt.io/qt-5/qspinbox.html
        • For floating point numbers: https://doc.qt.io/qt-5/qdoublespinbox.html
        H Offline
        H Offline
        Hayri
        wrote on last edited by
        #3

        @jsulm
        i will use this in lineEdit but
        thanks

        JonBJ 1 Reply Last reply
        0
        • H Hayri

          @jsulm
          i will use this in lineEdit but
          thanks

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

          @Hayri Then use the QLineEdit::setValidator().

          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