Auto-highlighting a character name

A nice addition to improve the readability of the comic script would be to provide auto-highlighting for the character names. It turns out that Qt exposes a QSyntaxHighlighter (http://doc.qt.io/qt-5.9/qsyntaxhighlighter.html) component, which just does this. It can be attached to a QTextDocument (http://doc.qt.io/qt-5.9/qtextdocument.html), such as the default text document, which is embedded in our QTextEdit script editor.

A full tutorial to implement a custom syntax highlighter is available at http://doc.qt.io/qt-5.9/qtwidgets-richtext-syntaxhighlighter-example.html.

We will make use of a regular expression to find any sequence of type > character name: and display it as bold, blue text. To achieve this, ...

Get End to End GUI Development with Qt5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.