Qt 6.11 is out! See what's new in the release
blog
[SOLVED]Syntax highlighting
Qt.io webservices
3
Posts
2
Posters
1.5k
Views
1
Watching
-
Hi,
Is there a way to tune the syntax highlighter a little better? It often seems kinda random and I'm not sure the rules are the proper ones for c++.
Some examples:
QString variable; someOtherVariable = variable;Type name and variable name are bold but it no longer applies below, where type is normal and variable is red and then normal again inside if statement:
QFile file("stuff"); if(file.open(QFile::ReadOnly) { /* ... */ }And now the variable is violet:
widget -> setStylesheet("color: red");And now a bogus keyword is recognized:
widget . setStylesheet("color: red");And now the variable and method are blue and string is not recognized anymore:
widget -> setStylesheet("QWidget { color: red; }"); -
Looks like the only reliable way is to use the triple backtick with the language:
```cpp
QString variable; someOtherVariable = variable; QFile file("stuff"); if(file.open(QFile::ReadOnly) { /* ... */ } widget -> setStylesheet("color: red"); widget . setStylesheet("color: red"); widget -> setStylesheet("QWidget { color: red; }");QString variable;someOtherVariable = variable;QFile file("stuff");if(file.open(QFile::ReadOnly) { /* ... */ }widget -> setStylesheet("color: red");widget . setStylesheet("color: red");widget -> setStylesheet("QWidget { color: red; }");