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

bool QString::startsWith ( const QString s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns true if the string starts with s; otherwise returns false.

If cs is Qt::CaseSensitive (the default), the search is case sensitive; otherwise the search is case insensitive.

snippets/qstring/main.cpp Widget::startsWithFunction() QString str str.startsWith("Car"); // returns false

See also:
endsWith()

Definition at line 2871 of file qstring.cpp.

References d.

Referenced by QResource::addSearchPath(), QTextCodec::availableCodecs(), QTextCodec::availableMibs(), QDir::cd(), Q3ComboBox::completionIndex(), QAbstractFileEngine::create(), Q3MimeSourceFactory::data(), QFSFileEngine::fileName(), Q3ListView::findItem(), Q3IconView::findItem(), Q3ListBox::findItem(), Q3IconView::findItemByName(), QUrl::fromLocalFile(), QDirModel::index(), QUrl::isParentOf(), QDBusUtil::isValidBusName(), QDBusUtil::isValidObjectPath(), QDBusUtil::isValidUniqueConnectionName(), QTranslator::load(), QAbstractItemModel::match(), QFSCompletor::pathFromIndex(), QColor::setNamedColor(), QCompleter::splitPath(), QFSCompletor::splitPath(), QClipboard::text(), QCoreApplication::translate(), and Q3UriDrag::unicodeUriToUri().

{
    if (d == &shared_null)
        return (s.d == &shared_null);
    if (d->size == 0)
        return s.d->size == 0;
    if (s.d->size > d->size)
        return false;
    if (cs == Qt::CaseSensitive) {
        return memcmp((char*)d->data, (char*)s.d->data, s.d->size*sizeof(QChar)) == 0;
    } else {
        uint last = 0;
        uint olast = 0;
        for (int i = 0; i < s.d->size; ++i)
            if (foldCase(d->data[i], last) != foldCase(s.d->data[i], olast))
                return false;
    }
    return true;
}


Generated by  Doxygen 1.6.0   Back to index