Extending Qt Creator Manual | SyntaxHighlighter

Extending Qt Creator Manual 4.5.2

# SyntaxHighlighter Class

(TextEditor::SyntaxHighlighter)

Inherited By: | VcsBase::BaseAnnotationHighlighter and VcsBase::DiffAndLogHighlighter

- List of all members, including inherited members

## Public Functions

| SyntaxHighlighter(QObject *parent = 0)
| SyntaxHighlighter(QTextDocument *parent)
| SyntaxHighlighter(QTextEdit *parent)
virtual | ~SyntaxHighlighter()
QTextDocument * | document() const
void | setDocument(QTextDocument *doc)
void | setExtraFormats(const QTextBlock &block, QVector<QTextLayout::FormatRange> &formats)
virtual void | setFontSettings(const TextEditor::FontSettings &fontSettings)
void | setNoAutomaticHighlighting(bool noAutomatic)

## Public Slots

void | rehighlight()
void | rehighlightBlock(const QTextBlock &block)

## Static Public Members

QList<QColor> | generateColors(int n, const QColor &background)

## Protected Functions

QTextBlock | currentBlock() const
int | currentBlockState() const
QTextBlockUserData * | currentBlockUserData() const
QTextCharFormat | format(int pos) const
QTextCharFormat | formatForCategory(int categoryIndex) const
void | formatSpaces(const QString &text, int start = 0, int count = INT_MAX)
virtual void | highlightBlock(const QString &text)
int | previousBlockState() const
void | setCurrentBlockState(int newState)
void | setCurrentBlockUserData(QTextBlockUserData *data)
void | setDefaultTextFormatCategories()
void | setFormat(int start, int count, const QTextCharFormat &format)
void | setFormat(int start, int count, const QColor &color)
void | setFormat(int start, int count, const QFont &font)
void | setFormatWithSpaces(const QString &text, int start, int count, const QTextCharFormat &format)
void | setTextFormatCategories(int count, std::function<TextStyle( int ) > formatMapping)

## Member Function Documentation

### SyntaxHighlighter::SyntaxHighlighter(QObject *parent = 0)

Default constructs an instance of SyntaxHighlighter.

### SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent)

Default constructs an instance of SyntaxHighlighter.

### SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent)

Default constructs an instance of SyntaxHighlighter.

### `[virtual]` SyntaxHighlighter::~SyntaxHighlighter()

Destroys the instance of SyntaxHighlighter. The destructor is virtual.

### `[protected]` QTextBlock SyntaxHighlighter::currentBlock() const

### `[protected]` int SyntaxHighlighter::currentBlockState() const

See also setCurrentBlockState().

### `[protected]` QTextBlockUserData *SyntaxHighlighter::currentBlockUserData() const

See also setCurrentBlockUserData().

### QTextDocument *SyntaxHighlighter::document() const

See also setDocument().

### `[protected]` QTextCharFormat SyntaxHighlighter::format(int pos) const

See also setFormat().

### `[protected]` QTextCharFormat SyntaxHighlighter::formatForCategory(int categoryIndex) const

### `[protected]` void SyntaxHighlighter::formatSpaces(const QString &text, int start = 0, int count = INT_MAX)

### `[static]` QList<QColor> SyntaxHighlighter::generateColors(int n, const QColor &background)

### `[virtual protected]` void SyntaxHighlighter::highlightBlock(const QString &text)

### `[protected]` int SyntaxHighlighter::previousBlockState() const

### `[slot]` void SyntaxHighlighter::rehighlight()

### `[slot]` void SyntaxHighlighter::rehighlightBlock(const QTextBlock &block)

### `[protected]` void SyntaxHighlighter::setCurrentBlockState(int newState)

See also currentBlockState().

### `[protected]` void SyntaxHighlighter::setCurrentBlockUserData(QTextBlockUserData *data)

See also currentBlockUserData().

### `[protected]` void SyntaxHighlighter::setDefaultTextFormatCategories()

### void SyntaxHighlighter::setDocument(QTextDocument *doc)

See also document().

### void SyntaxHighlighter::setExtraFormats(const QTextBlock &block, QVector<QTextLayout::FormatRange> &formats)

### `[virtual]` void SyntaxHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings)

### `[protected]` void SyntaxHighlighter::setFormat(int start, int count, const QTextCharFormat &format)

See also format().

### `[protected]` void SyntaxHighlighter::setFormat(int start, int count, const QColor &color)

### `[protected]` void SyntaxHighlighter::setFormat(int start, int count, const QFont &font)

### `[protected]` void SyntaxHighlighter::setFormatWithSpaces(const QString &text, int start, int count, const QTextCharFormat &format)

### void SyntaxHighlighter::setNoAutomaticHighlighting(bool noAutomatic)

### `[protected]` void SyntaxHighlighter::setTextFormatCategories(int count, std::function<TextStyle( int ) > formatMapping)