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

QString QString::mid ( int  i,
int  len = -1 
) const

Returns a string that contains the len characters of this string, starting at position i.

Returns an empty string if index i exceeds the length of the string. If there are less than len characters available in the string starting at position i, or if len is -1 (the default), the function returns all characters that are available from position i.


        QString x = "Nine pineapples";
        QString y = x.mid(5, 4);            // y == "pine"
        QString z = x.mid(5);               // z == "pineapples"

See also:
left(), right()

Definition at line 2718 of file qstring.cpp.

References QString().

Referenced by QTextCodec::availableMibs(), QFileInfo::completeSuffix(), QPlastiqueStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsXPStyle::drawControl(), QUrl::fromLocalFile(), QDate::fromString(), QDateTime::fromString(), QTime::fromString(), Q3TextEdit::optimParseTags(), Q3TextEdit::optimSelectedText(), Q3TextEdit::optimSetTextFormat(), Q3Url::parse(), Q3HttpResponseHeader::parseLine(), Q3HttpHeader::parseLine(), QHttpResponseHeader::parseLine(), QHttpHeader::parseLine(), Q3TextEdit::pasteSubType(), QXmlNamespaceSupport::processName(), QLocale::QLocale(), QUuid::QUuid(), Q3DateEdit::removeFirstNumber(), Q3TimeEdit::removeFirstNumber(), Q3TimeEdit::removeLastNumber(), Q3DateEdit::removeLastNumber(), Q3FileDialog::setDir(), Q3Url::setEncodedPathAndQuery(), QUrl::setUrl(), split(), QXmlNamespaceSupport::splitName(), QFileInfo::suffix(), and QClipboard::text().

    if (d == &shared_null || i >= d->size)
        return QString();
    if (len < 0)
        len = d->size - i;
    if (i < 0) {
        len += i;
        i = 0;
    if (len + i > d->size)
        len = d->size - i;
    if (i == 0 && len == d->size)
        return *this;
    return QString((const QChar*) d->data + i, len);

Generated by  Doxygen 1.6.0   Back to index