I want to click my mouse on a QTextEdit, and get the text position of that click from within the document. Where would my click be if the click resulted in a character being inserted? I'm hoping to subvert some of QTextEdit's functionality, so I do not want to simply get the position from the QTextCursor after the click has been processed. Basically I'm reimplementing mousePressEvent myself, but still need to know what the closest character gap is.
Asked
Active
Viewed 585 times
0
-
Could you explain me better – eyllanesc Feb 24 '17 at 05:19
-
You have to convert viewport coordinates to a position in the document, so the only choice is [cursorForPosition](https://doc.qt.io/qt-4.8/qtextedit.html#cursorForPosition). – ekhumoro Feb 24 '17 at 17:22