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

QString & QString::remove ( int  position,
int  n 
)

Removes n characters from the string, starting at the given position index, and returns a reference to the string.

If the specified position index is within the string, but position + n is beyond the end of the string, the string is truncated at the specified position.

snippets/qstring/main.cpp Widget::removeFunction() QString s // s == "Meal"

See also:
insert(), replace()

Definition at line 1406 of file qstring.cpp.

References detach(), resize(), and size().

Referenced by Q3IconViewItem::calcTmpText(), QSpinBox::fixup(), QDoubleSpinBox::fixup(), Q3UriDrag::localFileToUri(), Q3TextEdit::optimParseTags(), Q3Url::parse(), Q3Url::Q3Url(), QDir::relativeFilePath(), QFileDialog::selectFile(), Q3Url::setFileName(), QSpinBox::textFromValue(), QDoubleSpinBox::textFromValue(), QUrl::toLocalFile(), Q3UriDrag::uriToLocalFile(), and QGLContext::~QGLContext().

{
    if (pos < 0)
        pos += d->size;
    if (pos < 0 || pos >= d->size) {
        // range problems
    } else if (pos + len >= d->size) {  // pos ok
        resize(pos);
    } else if (len > 0) {
        detach();
        memmove(d->data + pos, d->data + pos + len,
                (d->size - pos - len + 1) * sizeof(ushort));
        d->size -= len;
    }
    return *this;
}


Generated by  Doxygen 1.6.0   Back to index