QTextEdit with custom object inside. How to retrieve them by cursor position?
Hi all
I have a QTextEdit control filled by a custom object instead of standard letters. For insert object I got the example from qt package as follow:
Code:
cursor.
insertText(QString(QChar::ObjectReplacementCharacter), MyCharFormat
);
textEdit->setTextCursor(cursor);
It word very well. Now I want to activate the mouse cursor tracking for the editor and get the object currently under the cursor. I use a code similat to the following:
Code:
int textCursorPosition = document()->documentLayout()->hitTest( event->pos(), Qt::FuzzyHit );
This function will return the cursot position of the object under the mouse pos but, once got this coordinate, how to get the pointer to my custom object structure? In case of standard letter I could use the following code:
Code:
QChar character
( textDocument
->characterAt
( textCursorPosition
) );
But what about custom object?
Thank you