I am using some regular expressions in my application. I am making changes to the application mentioned below-:
http://qt-project.org/doc/qt-4.8/ric...ghlighter.html
Making changes to the highlighter.cpp file of the application, I have done something like this :-
quotationFormat.setForeground(Qt::blue);
rule.format = quotationFormat; // for double quotes
highlightingRules.append(rule);
plus.setForeground(Qt::red);
rule.format = plus;
highlightingRules.append(rule);
QTextCharFormat plus,quotationformat;
quotationFormat.setForeground(Qt::blue);
rule.pattern = QRegExp("\".*\"");
rule.format = quotationFormat; // for double quotes
highlightingRules.append(rule);
plus.setForeground(Qt::red);
rule.pattern = QRegExp("\\+");
rule.format = plus;
highlightingRules.append(rule);
To copy to clipboard, switch view to plain text mode
The problem I am facing is that if '+' is written inside double quotes , the quotation format rules does not apply on it. Something like this-:
If I write + outside quotes, it is displayed in red like-:
But If I write it inside quotes like-:
"Adding 1 + 2 makes 3...."
..
I want that + should also appear in blue when i type it inside quotes. Can anyone help me what mistake I am making??
Bookmarks