I have a subclass of QPlainTextEdit with createMimeDataFromSelection function overriden.
Text contains plain text and my QTextObjects.
In createMimeDataFromSelection I want to get all TextObjects inside selection. The only working way
I've managed to get by checking every QTextCursor position of the selection:

Qt Code:
  1. int endpos = cursor.position();
  2. for (int i = cursor.anchor(); i <= endpos; ++i)
  3. {
  4. cursor.setPosition(i);
  5. qDebug() << cursor.position();
  6. int type = cursor.charFormat().objectType();
  7. if (type == MainDialog::MyTextFormat)
  8. {
  9. qDebug() << "My format";
  10. }
  11. }
To copy to clipboard, switch view to plain text mode 

This looks cumbersome to me.
I tested cursor.movePosition function with various argument values but it always skipped my TextObject positions
to the end of the selection.
Ideally I want to skip all the plaintext till next TextObject position in the selection.

So, am I missing the proper way?