Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Start next text block below an image in a QTextDocument
Forum Updated to NodeBB v4.3 + New Features

Start next text block below an image in a QTextDocument

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.8k 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.
  • D Offline
    D Offline
    daviddoria
    wrote on last edited by
    #1

    Currently I insert a block containing a newline character to do this:
    @
    QTextDocument* myDocument = new QTextDocument(textEdit);
    textEdit->setDocument(myDocument);
    QTextCursor* myCursor = new QTextCursor(myDocument);

      // Insert an image
      QTextImageFormat imageFormat;
      imageFormat.setName("logo.jpg");
      myCursor->insertImage(imageFormat, QTextFrameFormat::InFlow);
      myCursor->insertText("\n");
      
      // Insert normal text
      myCursor->movePosition(QTextCursor::End);
      myCursor->insertText("test");
    

    @

    This seems pretty hacky. Is there a better way to make the next block of text start below the image, rather than to the right of it?

    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