O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required