Thoughts on the "default syntax highlighter for QTextEdit" task

Aurélien Gâteau agateau at kde.org
Thu Aug 1 16:33:49 UTC 2013


Hi,

I assigned myself to this Qt5-epic task:

> Allow to register a default syntax highlighter type for QTextEdit, the KDE 
> backend would register the spell checking one coming from sonnet as default

After some investigations, it turns out the highlighter is set by QTextEdit on 
the QTextDocument it creates. My idea to implement this task is the following:

1. Introduce a new QPA class:

	class QDefaultSyntaxHighlighterFactory
	{
	public:
		virtual QSyntaxHighlighter *create();
	}

2. Add a new method to QPlatformIntegration to return an instance of this 
class.

3. Change QTextEditPrivate::init() so that when it creates its QTextDocument, 
it tries to create an highlighter with 
QDefaultSyntaxHighlighterFactory::create() and assign it to the QTextDocument.

4. Implement QDefaultSyntaxHighlighterFactory in our integration plugin to 
return the sonnet plugin.

Should work, but extending the QPlatformIntegration class for such a feature 
feels a bit overkill to me. Is there a simpler alternative?

Aurélien


More information about the Kde-frameworks-devel mailing list