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. Position of images of QImages in QTextDocument.

Position of images of QImages in QTextDocument.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 361 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
    DrZod
    wrote on last edited by
    #1

    How can i find the position of images in QTextDocument?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      You would loop over the QTextBlock and find image ones.
      Im not sure it has a x,y if that is what you are looking for.

      void MainWindow::ImageInfo()
      {
          QTextBlock bl = ui->textarea->document()->begin();
          while (bl.isValid()) {
              QTextBlock::iterator it;
      
              for (it = bl.begin(); !(it.atEnd()); ++it) {
                  QTextFragment currentFragment = it.fragment();
                  if (currentFragment.isValid()) {
                      if (currentFragment.charFormat().isImageFormat()) {
                          QTextImageFormat imgFmt = currentFragment.charFormat().toImageFormat();
                          QString image_name = imgFmt.name();
                          qDebug() << "Image " << image_name;
      
                      } // if image
                  }
              }
              bl = bl.next();
          }
      }
      

      Credits to some russian site. :)

      1 Reply Last reply
      2

      • Login

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