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

Vitali Baumtrok aedit at baumtrok.de
Wed May 28 17:12:39 CEST 2014


Hello,

is there a possibility to set the QTextDocument in BaseTextEditorWidget 
of the TextEditor plugin?

I need to integrate a class which derives from QTextDocument with the 
BaseTextEditorWidget.

Qt Creator 3.1.0 is used.


Here is the problem in TextEditor plugin source code:

BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) :
     m_fontSettingsNeedsApply(false),
     m_document(new QTextDocument(q)),  // <=== QTextDocument 
instantiation !
     m_highlighter(0),
     m_indenter(new Indenter),
     m_fileIsReadOnly(false),
     m_autoSaveRevision(-1)
{
}

BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
{
     connect(d->m_document, SIGNAL(modificationChanged(bool)), d, 
SLOT(onModificationChanged(bool)));
     connect(d->m_document, SIGNAL(modificationChanged(bool)), this, 
SIGNAL(changed()));
     connect(d->m_document, SIGNAL(contentsChanged()), this, 
SIGNAL(contentsChanged()));
     ...
}


example code:
BaseTextEditorWidget *btew = new BaseTextEditorWidget;
btew->setDocument(new QTextDocument(btew));

result:
SOFT ASSERT: "documentLayout" in file 
/home/qt-creator-3.1.0/src/plugins/texteditor/basetexteditor.cpp, line 585
SOFT ASSERT: "documentLayout" in file 
/home/qt-creator-3.1.0/src/plugins/texteditor/basetexteditor.cpp, line 2800
SOFT ASSERT: "documentLayout" in file 
/home/qt-creator-3.1.0/src/plugins/texteditor/basetexteditor.cpp, line 2800
SOFT ASSERT: "documentLayout" in file 
/home/qt-creator-3.1.0/src/plugins/texteditor/basetexteditor.cpp, line 2800
SOFT ASSERT: "documentLayout" in file 
/home/qt-creator-3.1.0/src/plugins/texteditor/basetexteditor.cpp, line 2800
SOFT ASSERT: "documentLayout" in file 
/home/qt-creator-3.1.0/src/plugins/texteditor/basetexteditor.cpp, line 2800
and so on....

The editor is empty, i.e. shows no text.


It seems that it is impossible to do what I want. Did I miss something 
or is there a workaround?



More information about the Qt-creator mailing list