c++ - How do I use QTextBlock? -


I'm totally new in C ++ and QT.

I QTextBlocks with a QTextEdit object, how do I do this?

Example If I have "fish coming" sentence then how do I put each word in my own QTextBlock and block that block Added to QTextEdit , or have I misunderstood how QTextBlock actually works?

QTextEdit via a QString Will add your content:

  QTextEdit myEdit ("fish are coming");  

This also allows you to use a QTextDocument , which holds the blocks of text QTextDocument itself QString can accept:

  QTextEdit myEdit; QTextDocument * myDocument = New QTextDocument ("fish are coming", & amp; myEdit); MyEdit.setDocument (myDocument); However, "If you need to create a new text block, or if you need to modify the contents of a document while checking its contents,  QTextCursor . Use the cursor-based interface provided by> code> instead. "(Note, I've added the  QTextBlockFormat  lines to clear the blocks.) 

  QTextEdit myEdit; QTextDocument * myDocument = new QTextDocument (& myEdit); MyEdit.setDocument (myDocument); QTextCursor * myCursor = new QTextCursor (myDocument); QTextBlockFormat format; Format.setBackground (Qt :: Red); MyCursor- & gt; SetBlockFormat (format); MyCursor-> InsertText ("the"); Format.setBackground (QT :: green); MyCursor- & gt; InsertBlock (format); MyCursor-> InsertText ("fish"); Format.setBackground (QT :: Yellow); MyCursor- & gt; InsertBlock (format); MyCursor-> InsertText ("are"); Format.setBackground (Qt :: Red); MyCursor- & gt; InsertBlock (format); MyCursor- & gt; InsertText ("Coming!"); Format.setBackground (QT :: green); MyCursor- & gt; InsertBlock (format); MyCursor-> InsertText (QString (% 1 block). Arg (myDocument-> BlockCount ()); MyEdit.show ();  

It seems that I have to go through you. Do you think you have QTextBlock s?


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -