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

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 2840 of file qstring.cpp.

References QString().

Referenced by QTextCodec::availableMibs(), QFileInfo::completeSuffix(), QAbstractFileEngine::create(), QWindowsVistaStyle::drawControl(), 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(), Q3HttpResponseHeader::parseLine(), Q3HttpHeader::parseLine(), QHttpResponseHeader::parseLine(), QHttpHeader::parseLine(), Q3TextEdit::pasteSubType(), QFSCompletor::pathFromIndex(), QSqlResult::prepare(), QXmlNamespaceSupport::processName(), QUuid::QUuid(), Q3DateEdit::removeFirstNumber(), Q3TimeEdit::removeFirstNumber(), Q3TimeEdit::removeLastNumber(), Q3DateEdit::removeLastNumber(), Q3FileDialog::setDir(), Q3Url::setEncodedPathAndQuery(), QUrl::setUrl(), split(), QXmlNamespaceSupport::splitName(), QCompleter::splitPath(), QFSCompletor::splitPath(), QFileInfo::suffix(), QClipboard::text(), QImage::textLanguages(), QImage::textList(), QCoreApplication::translate(), Q3TextStream::ts_getbuf(), and Q3TextStream::ts_getline().

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


Generated by  Doxygen 1.6.0   Back to index