[Qt-creator] Syntax highlighting, EditorWidget and XML

Ziller Eike Eike.Ziller at theqtcompany.com
Tue Dec 22 09:31:06 CET 2015


> On Dec 21, 2015, at 10:10 PM, Knut Petter Svendsen <knutpett+qtcreator at pvv.org> wrote:
> 
> Hi!
> 
> I'm implementing a small plugin with my own EditorWidget inheriting TextEditorWidget to get my own code navigation.
> The editor is for a file based on XML. I've implemented findLinkAt and that works. Since the file has xml-syntax I'd
> like it to use XML syntax highlighting. How do I get that without having to implement my own syntax highlighter?
> 
> I've tried to make my own mime-type and let it be a sub-class-of application/xml, but that doesn't help. It helps by
> adding my file extension to application/xml (Tools->...MIME Types) but then it seems to ruin for my EditorWidget
> (wrong editor opened?)
> 
> Any help would be appreciated!

I think making your mime type a subclass of xml and setting setUseGenericHighlighter(true) in your editor factory (see PlainTextEditorFactory) should be enough to do the job.

Br, Eike


-- 
Eike Ziller, Senior Software Engineer - The Qt Company GmbH
 
The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list