本文整理汇总了C++中QRegularExpression::errorString方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpression::errorString方法的具体用法?C++ QRegularExpression::errorString怎么用?C++ QRegularExpression::errorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegularExpression
的用法示例。
在下文中一共展示了QRegularExpression::errorString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: highlightBlock
void MarkupHighlighter::highlightBlock(const QString &text)
{
if (FORMATTING.empty()){
qWarning() << "Not given any formatting, so not highlighting.";
return;
}
if (text.isEmpty()) return;
int start=0, end=0, highlightLength = 0;
QRegularExpression re;
QTextCharFormat textFormat;
for (QString exp : TOKENS.keys()){
setCurrentBlockState(0);
start = 0, end = 0;
re = QRegularExpression(exp);
if (!re.isValid()){
QString message = "Invalid regular expression \""
+ re.pattern() + "\" :" + re.errorString();
qFatal("%s", message.toStdString().data());
return;
}
if (previousBlockState() != 1)
start = re.match(text).capturedStart();
while (start >= 0){
QRegularExpressionMatch match = re.match(text, start);
end = match.capturedEnd();
if (end == -1 || (end == start && end != 0)){
setCurrentBlockState(1);
highlightLength = text.length();
} else {
highlightLength = match.capturedLength();
}
QTextCharFormat baseFormat = currentBlock().blockFormat().toCharFormat();
MarkupHighlighter::MarkupToken tok = TOKENS[exp];
if (!FORMATTING.contains(tok)){
qWarning() << "Could not find" << tok;
break;
}
const StyleProxy *styleProxy = FORMATTING[tok];
textFormat = styleProxy->toFormat(baseFormat);
setFormat(start, highlightLength, textFormat);
qDebug() << "highlightBlock";
qDebug() << "Formatting"
<< "token" << tok
<< "with regex=" << exp
<< ", string="
<< text.mid(start, highlightLength)
<< "\n"
<< " Bold?" << textFormat.font().bold() << "\n"
<< " Italic?" << textFormat.font().italic() << "\n"
<< " Size:" << textFormat.font().pointSize() << "\n"
<< " Background:" << textFormat.background().color();
start = re.match(text, end).capturedStart();
// This should not be 0 again. If it is, that means our search has
// come up empty.
if (start == 0)
start = -1;
}
}
}
示例2: setProjectNameRegularExpression
void ProjectIntroPage::setProjectNameRegularExpression(const QRegularExpression ®Ex)
{
Q_ASSERT_X(regEx.isValid(), Q_FUNC_INFO, qPrintable(regEx.errorString()));
d->m_projectNameValidator.setRegularExpression(regEx);
}