Редактирование: Syntax Highlighting in QTextEdit
Материал из Wiki.crossplatform.ru
Внимание: Вы не представились системе. Ваш IP-адрес будет записан в историю изменений этой страницы.
Правка может быть отменена. Пожалуйста, просмотрите сравнение версий, чтобы убедиться, что это именно те изменения, которые вас интересуют, и нажмите «Записать страницу», чтобы изменения вступили в силу.
Текущая версия | Ваш текст | ||
Строка 1: | Строка 1: | ||
- | + | ||
+ | |||
+ | __NOTOC__ | ||
<div class="introduction"> | <div class="introduction"> | ||
The appropriate use of colors and fonts to highlight the differentelements of programming and markup languages helpsthe brain to grasp document structures. By flaggingsyntax errors, interactive syntax highlighting also helpsreduce the time spent in the "compile, run, test" cycle.Highlighting can even be used to flag spelling mistakes in textdocuments. With Qt, adding syntax highlighting to a QTextEdit is veryeasy, as this article will demonstrate. | The appropriate use of colors and fonts to highlight the differentelements of programming and markup languages helpsthe brain to grasp document structures. By flaggingsyntax errors, interactive syntax highlighting also helpsreduce the time spent in the "compile, run, test" cycle.Highlighting can even be used to flag spelling mistakes in textdocuments. With Qt, adding syntax highlighting to a QTextEdit is veryeasy, as this article will demonstrate. | ||
- | + | *[[#subclassingqsyntaxhighlighter | Subclassing QSyntaxHighlighter]] | |
+ | *[[#keepingtrackofstateinformation | Keeping Track of State Information]] | ||
+ | *[[#example | Example: A Basic HTML Highlighter]] | ||
+ | *[[#summary | Summary]] | ||
</div> | </div> | ||
Qt 3.1 introduced [[Qt:Документация_4.3.2/qsyntaxhighlighter | QSyntaxHighlighter]]as an abstract base class to provide syntax highlighting to a[[Qt:Документация_4.3.2/qtextedit | QTextEdit]]. In Qt 4, the class was moved to the<tt>Qt3Support</tt> library, and a new[[Qt:Документация_4.3.2/qsyntaxhighlighter | QSyntaxHighlighter]] class took its place.The new [[Qt:Документация_4.3.2/qsyntaxhighlighter | QSyntaxHighlighter]] class isbased on Qt 4's new rich text engine and works on arbitrary[[Qt:Документация_4.3.2/qtextdocument | QTextDocument]] objects. In this article, wewill concentrate on the new class. | Qt 3.1 introduced [[Qt:Документация_4.3.2/qsyntaxhighlighter | QSyntaxHighlighter]]as an abstract base class to provide syntax highlighting to a[[Qt:Документация_4.3.2/qtextedit | QTextEdit]]. In Qt 4, the class was moved to the<tt>Qt3Support</tt> library, and a new[[Qt:Документация_4.3.2/qsyntaxhighlighter | QSyntaxHighlighter]] class took its place.The new [[Qt:Документация_4.3.2/qsyntaxhighlighter | QSyntaxHighlighter]] class isbased on Qt 4's new rich text engine and works on arbitrary[[Qt:Документация_4.3.2/qtextdocument | QTextDocument]] objects. In this article, wewill concentrate on the new class. |