Hello,
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:
int endpos = cursor.position(); for (int i = cursor.anchor(); i <= endpos; ++i) { cursor.setPosition(i); qDebug() << cursor.position(); int type = cursor.charFormat().objectType(); if (type == MainDialog::MyTextFormat) { qDebug() << "My format"; } }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?
Thanks
Bookmarks