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 check string contains more than one dot in qt ?
Forum Updated to NodeBB v4.3 + New Features

How to check string contains more than one dot in qt ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 323 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    I want to put validation for entered typed data by user.

    maximum character in typed data is 3 and it not contain more than one dot.

    so i have written below code to implement it where MINIMUM_BG =0.0 & MAXIMUM_BG =5.0 .

    But below logic become wrong when user enter ".1.". so how to put validation for this type of string when it contain more than one dot in qt?

    my key board contains " 0-9 " and one " . " .

    if((sTypedData.toFloat()< MINIMUM_BG)||(sTypedData.toFloat() > MAXIMUM_BG) || sTypedData.contains("..") )
    WrongValue(sTypedData);
    else
    CorrectValue(sTypedData);

    jsulmJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      I want to put validation for entered typed data by user.

      maximum character in typed data is 3 and it not contain more than one dot.

      so i have written below code to implement it where MINIMUM_BG =0.0 & MAXIMUM_BG =5.0 .

      But below logic become wrong when user enter ".1.". so how to put validation for this type of string when it contain more than one dot in qt?

      my key board contains " 0-9 " and one " . " .

      if((sTypedData.toFloat()< MINIMUM_BG)||(sTypedData.toFloat() > MAXIMUM_BG) || sTypedData.contains("..") )
      WrongValue(sTypedData);
      else
      CorrectValue(sTypedData);

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

      @Qt-embedded-developer
      " How to check string contains more than one dot in qt ?" - https://doc.qt.io/qt-5/qstring.html#count-2

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

      Q 1 Reply Last reply
      5
      • jsulmJ jsulm

        @Qt-embedded-developer
        " How to check string contains more than one dot in qt ?" - https://doc.qt.io/qt-5/qstring.html#count-2

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #3

        @jsulm Thanks.

        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