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

QString QString::mid ( int  position,
int  n = -1 
) const

Returns a string that contains n characters of this string, starting at the specified position index.

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

Example:

snippets/qstring/main.cpp Widget::midFunction() QString x QString z

See also:
left(), right()

Definition at line 2760 of file qstring.cpp.

References QString().

Referenced by QTextCodec::availableMibs(), QFileInfo::completeSuffix(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsXPStyle::drawControl(), QItemDelegate::drawDisplay(), QUrl::fromLocalFile(), QDate::fromString(), QDateTime::fromString(), QTime::fromString(), QDBusUtil::isValidUniqueConnectionName(), QLibraryInfo::location(), Q3TextEdit::optimParseTags(), Q3TextEdit::optimSelectedText(), Q3TextEdit::optimSetTextFormat(), Q3Url::parse(), QHttpResponseHeader::parseLine(), Q3HttpHeader::parseLine(), Q3HttpResponseHeader::parseLine(), QHttpHeader::parseLine(), Q3TextEdit::pasteSubType(), QXmlNamespaceSupport::processName(), QUuid::QUuid(), Q3DateEdit::removeFirstNumber(), Q3TimeEdit::removeFirstNumber(), Q3TimeEdit::removeLastNumber(), Q3DateEdit::removeLastNumber(), Q3FileDialog::setDir(), Q3Url::setEncodedPathAndQuery(), QUrl::setUrl(), split(), QXmlNamespaceSupport::splitName(), QCompleter::splitPath(), QFileInfo::suffix(), QClipboard::text(), QCoreApplication::translate(), Q3TextStream::ts_getbuf(), and Q3TextStream::ts_getline().

{
    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