Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Bug in QSyntaxHighlighter?
Forum Updated to NodeBB v4.3 + New Features

Bug in QSyntaxHighlighter?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.4k 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.
  • O Offline
    O Offline
    orbit
    wrote on last edited by
    #1

    Hello,

    I am using Code from an old version of Qt (4.1 or something like that) and i think there is a bug in the new version (4.8 or 4.7).
    In the old version everything worked well, the full text appeared. But Compiling and running it with newer versions, there vanish some lines, my observation was: the first line, where NO RULE had matched, i.e NO FORMAT had been set in the line, is visible. Following lines with no highlighting are not shown, but still exist in the window (if I vcall "getPlaintext()" the whole text is returend.

    I solved it now by this:
    @
    QTextCharFormat normalF;
    normalF.setForeground(QBrush((new QColor(0,0,0))->toRgb()));

    bool highlighted = false;
    foreach (HighlightingRule rule, highlightingRules) {
    QRegExp [removed]rule.pattern);
    int index = text.indexOf(expression);
    while (index >= 0) {
    int length = expression.matchedLength();
    if(expression.cap().trimmed() !=""){
    setFormat(index, length, rule.format);
    highlighted = true;
    }
    index = text.indexOf(expression, index + length);
    }
    }
    if(!highlighted){
    setFormat(0, text.length(), normalF);
    }
    setCurrentBlockState(0);
    @

    What means I just use a format with black (normal text) for every line which is not highlighted.
    It works, but I would like to know whether thats a bug or a feature...

    best regard,
    Orbit

    1 Reply Last reply
    0

    • Login

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