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. checking QLineEdit for input.
Qt 6.11 is out! See what's new in the release blog

checking QLineEdit for input.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 510 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.
  • T Offline
    T Offline
    thomasGl
    wrote on last edited by
    #1

    Hello guys. I made QLineedit objects. i want to add them and output the result but only if all objects have a number . How can i check if all my objects have a number only than output the result.

    JonBJ 1 Reply Last reply
    0
    • T thomasGl

      Hello guys. I made QLineedit objects. i want to add them and output the result but only if all objects have a number . How can i check if all my objects have a number only than output the result.

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

      @thomasGl
      By looking in each one to see whether it has a number there and only proceeding if they all do. QString Class has a number of methods (e.g. toInt(), toDouble()) for determining if a string is a valid "number" (depending on what your definition of a number is) which take a bool *ok parameter to find out whether the string was valid. If you only want numbers to be entered into your edits consider adding a QValidator or changing to a QSpinBox-type widget?

      1 Reply Last reply
      1
      • T Offline
        T Offline
        thomasGl
        wrote on last edited by
        #3

        yes i want only numbers.

        JonBJ 1 Reply Last reply
        0
        • T thomasGl

          yes i want only numbers.

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

          @thomasGl
          Well that does not advance the conversation. Anyway you have the answer above. If you only accept integers or floating points it's easiest to start with a QSpinbox widget instead of a QLineEdit.

          1 Reply Last reply
          1
          • T Offline
            T Offline
            thomasGl
            wrote on last edited by
            #5

            yes thx it helps me

            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