I’m completely new to C++ and Qt.
I want to populate a QTextEdit object with QTextBlocks, how do I do that?
e.g. If I have the sentence “the fish are coming” how would I put each word into its own QTextBlock and add that block to QTextEdit, or have I misunderstood how QTextBlock actually works?
QTextEditwill let you add your contents via aQString:It also allows you to use a
QTextDocument, which holds blocks of text.The
QTextDocumentitself also can accept aQString:However, “If you need to create a new text block, or modify the contents of a document while examining its contents, use the cursor-based interface provided by
QTextCursorinstead.” (Qt documentation) (Note, I added theQTextBlockFormatlines to make it explicit where the blocks are.)Seems like a lot of effort to go through to me. Can you give any additional information on why you feel you need to use
QTextBlocks?