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

QString QTextBlock::text (  )  const

Returns the block's contents as plain text.

See also:
length() charFormat() blockFormat()

Definition at line 1115 of file qtextobject.cpp.

References QString::constData(), end(), QString::fromRawData(), length(), position(), and QString::reserve().

Referenced by QAccessibleTextEdit::text().

{
    if (!p || !n)
        return QString();

    const QString buffer = p->buffer();
    QString text;
    text.reserve(length());

    const int pos = position();
    QTextDocumentPrivate::FragmentIterator it = p->find(pos);
    QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); // -1 to omit the block separator char
    for (; it != end; ++it) {
        const QTextFragmentData * const frag = it.value();
        text += QString::fromRawData(buffer.constData() + frag->stringPosition, frag->size);
    }

    return text;
}


Generated by  Doxygen 1.6.0   Back to index