Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

int QString::toInt ( bool *  ok = 0,
int  base = 10 
) const

Returns the string converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.


snippets/qstring/main.cpp Widget::toIntFunction() QString str int dec

See also:
number(), toUInt(), toDouble()

Definition at line 5114 of file qstring.cpp.

References toLongLong().

Referenced by Q3DateEdit::addNumber(), Q3TimeEdit::addNumber(), Q3TableItem::alignment(), QTextCodec::availableMibs(), QDate::fromString(), QDateTime::fromString(), QTime::fromString(), QLibrary::isLibrary(), Q3DockArea::operator>>(), Q3Url::parse(), Q3HttpResponseHeader::parseLine(), QHttpResponseHeader::parseLine(), Q3DateEdit::removeFirstNumber(), Q3TimeEdit::removeFirstNumber(), Q3TimeEdit::removeLastNumber(), Q3DateEdit::removeLastNumber(), and vsprintf().

    qint64 v = toLongLong(ok, base);
    if (v < INT_MIN || v > INT_MAX) {
        if (ok)
            *ok = false;
        v = 0;
    return v;

Generated by  Doxygen 1.6.0   Back to index