QTextDocument doc; // ... populate the document with text ... QTextBlock block = doc.firstBlock(); // get the first block while (block.isValid()) { QString text = block.text(); // get the text of the block // ... do something with the text ... block = block.next(); // move to the next block }
QTextEdit editor; // ... populate the editor with text ... QTextCursor cursor = editor.textCursor(); // get the cursor cursor.movePosition(QTextCursor::End); // move to the end of the document cursor.insertBlock(); // insert a new block at the endThe package library for QTextBlock is QtGui.