[Qt-creator] TextEditor plugin: how to set QTextDocument in BaseTextEditorWidget?

Thorbjørn Lindeijer thorbjorn at lindeijer.nl
Wed May 28 21:32:19 CEST 2014


On 28.05.2014 21:25, Thorbjørn Lindeijer wrote:
> So what you need to do is for your text document is to make sure it has
> this custom layout subclass set on it as well. This code is found in the
> BaseTextDocument constructor:
>
>>      BaseTextDocumentLayout *documentLayout = new BaseTextDocumentLayout(d->m_document);
>>      d->m_document->setDocumentLayout(documentLayout);

Sorry, I think my instructions are rather misleading. The 
BaseTextEditorWidget is only meant to be used with a BaseTextDocument. 
You should probably not use its setTextDocument function at all, which 
only happens to be available because it's a subclass of the 
QPlainTextEdit widget.

If you need to integrate a class that derives from QTextDocument, you 
should probably look into changing your own class to derive from the 
BaseTextDocument instead.

Regards,
Bjørn



More information about the Qt-creator mailing list