Unsolved QTextDocument: get formated text
-
Hi guys,
I need to get formated words (misspeling underlined) from QTextDocument.
How do I get words with specific format and their position in document?I had something like...
for( auto textBlock = document()->begin(); textBlock != document()->end(); textBlock = textBlock.next() ) { qDebug() << "textBlock::text: " << textBlock.text(); auto formats = textBlock.textFormats(); for (auto t = textBlock.begin(); t != textBlock.end(); ++t) { qDebug() << ""; auto fragment = t.fragment(); qDebug() << fragment.text(); auto format = fragment.charFormat(); qDebug() << format.fontUnderline(); qDebug() << format.underlineStyle(); qDebug() << format.underlineColor(); qDebug() << ""; } }
But that returned the entire text in document as only element and without any formating.
How else to get it? Or how to get to individual elements?
-
QTextEdit::document()->textCursor().block().layout()->formats();