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

[SOLVED]Syntax highlighting

Scheduled Pinned Locked Moved Qt.io webservices
3 Posts 2 Posters 1.2k Views
  • 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.
  • C Offline
    C Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on 12 Mar 2015, 14:52 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
    • T Offline
      T Offline
      tekojo
      wrote on 12 Mar 2015, 15:16 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
      • T Offline
        T Offline
        tekojo
        wrote on 13 Mar 2015, 09:31 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

        1/3

        12 Mar 2015, 14:52

        • Login

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