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

void QPlainTextEdit::setDocument ( QTextDocument document  ) 

Makes document the new document of the text editor.

The parent QObject of the provided document remains the owner of the object. If the current document is a child of the text editor, then it is deleted.

The document must have a document layout that inherits QPlainTextDocumentLayout (see QTextDocument::setDocumentLayout()).

See also:
document()

Definition at line 1293 of file qplaintextedit.cpp.

References QTextDocument::documentLayout(), QPlainTextDocumentLayout::priv(), QObject::qobject_cast(), and QTextDocument::setDocumentLayout().

{
    Q_D(QPlainTextEdit);
    QPlainTextDocumentLayout *documentLayout = 0;

    if (!document) {
        document = new QTextDocument(d->control);
        documentLayout = new QPlainTextDocumentLayout(document);
        document->setDocumentLayout(documentLayout);
    } else {
        documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout());
        if (!documentLayout) {
            qWarning("QPlainTextEdit::setDocument: Document set does not support QPlainTextDocumentLayout");
            return;
        }
    }
    d->control->setDocument(document);
    if (!documentLayout->priv()->mainViewPrivate)
        documentLayout->priv()->mainViewPrivate = d;
    d->documentLayoutPtr = documentLayout;
    d->updateDefaultTextOption();
    d->relayoutDocument();
}


Generated by  Doxygen 1.6.0   Back to index