Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Start next text block below another text block in a QTextDocument
Forum Updated to NodeBB v4.3 + New Features

Start next text block below another text block in a QTextDocument

Scheduled Pinned Locked Moved C++ Gurus
1 Posts 1 Posters 943 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    guru
    wrote on last edited by
    #1

    Hi,
    Currently I used a Qtextedit and separate text as blocks and gives different colors for each blocks, I use QTextblockFormat in QTextDocument. This display each block one by one, but I need parallel blocks, Following is my code,

    @QTextDocument* myDocument = new QTextDocument(ui->textedit);
    textedit->setDocument(myDocument);
    QTextCursor* myCursor = new QTextCursor(myDocument);

    QTextBlockFormat format;
    format.setNonBreakableLines(true);
    format.setBackground(Qt::green);
    format.setAlignment(Qt::AlignHCenter);
    
    myCursor->setBlockFormat(format);
    myCursor->insertText("Block1 ");
    
    
    format.setBackground(Qt::red);
    myCursor->insertBlock(format);
    myCursor->insertText("Block2 ");
    myCursor->insertHtml("<br>");
    myCursor->insertText("Block2");
    
    
    format.setBackground(Qt::yellow);
    myCursor->insertBlock(format);
    myCursor->insertText("Block3");@
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved