0
public boolean isDoubleValue(String s) {
        try {
            Double.valueOf(s);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

But i want to convert this method into QT cpp. Can any one help me?

Thanks, Nagaraju

3
  • See this: stackoverflow.com/questions/5932391/… Commented May 9, 2011 at 4:34
  • I want it for QT. so better to use QT library Commented May 9, 2011 at 4:38
  • QT is just a library on top of C and C++. Any answer that works with those should work with any QT compiled C++ application. Commented May 9, 2011 at 4:42

2 Answers 2

4

Since you need it in Qt (from your comment), you can use

double QString::toDouble ( bool * ok = 0 ) const.

And you can check the value of ok and return accordingly..

Sign up to request clarification or add additional context in comments.

Comments

0

You probably want atof(). This is a standard c library function for converting strings to doubles.

1 Comment

You probably don't want atof because, as the manual page says, "atof() does not detect errors." If QString::toDouble is undesirable, use strtod instead.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.