Traversing a QTextDocument via QRegExp and QTextCursor
-
Hello Community,
I'm still all new to Qt and going to write a recognizer for a AsciiDoc Documentstructure.
I choosed to do this with a list of QRegExp's.So if I do this, I get for '= 1 =' a correct result. But also for the following line. After the following line I don't get a result for '= 2 ='
This means following:
"
asdf
= 1 =
bsdf
= 2 =
"
should report a recognition for '= 1 =' and '= 2 ='. But my actual algorithm only reports
"
= 1 =
asdf
"I think I'm doing something wrong with the CursorMove.
Can anybody help me ?Here's my algorithm:
@
foreach(QRegExp searchPattern, *asciiDocSyntax)
{
crs = doc->find(searchPattern, crs, QTextDocument::FindWholeWords);if(!crs.isNull()) { crs.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor); qDebug() << "[parseDocument] found a matching block for pattern " << searchPattern.pattern() << " :" << crs.block().text(); }
}
@with these QRegExp:
@
// Header 1
asciiDocSyntax->push_back(QRegExp("^= .* =$"));// Header 2 asciiDocSyntax->push_back(QRegExp("^== .* ==$"));
@
Thank you very much !