aaditya190
12th December 2013, 07:42
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/richtext-syntaxhighlighter.html
Making changes to the highlighter.cpp file of the application, I have done something like this :-
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);
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-:
Adding 1 + 2 makes 3.
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??
http://qt-project.org/doc/qt-4.8/richtext-syntaxhighlighter.html
Making changes to the highlighter.cpp file of the application, I have done something like this :-
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);
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-:
Adding 1 + 2 makes 3.
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??