Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Qt.io webservices
  4. [SOLVED]Syntax highlighting
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Syntax highlighting

Scheduled Pinned Locked Moved Qt.io webservices
3 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by Chris Kawa
    #1

    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; }");
    
    1 Reply Last reply
    1
    • tekojoT Offline
      tekojoT Offline
      tekojo
      wrote on last edited by
      #2

      It tries to identify the language. And it does that for every snippet.

      I'll take a look how to make it more consistent.

      1 Reply Last reply
      0
      • tekojoT Offline
        tekojoT Offline
        tekojo
        wrote on last edited by
        #3

        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; }");
        
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved