Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to find current line number in QTextEdit?
Nastya Medvedeva last edited by
I need to get a position of a text cursor in QTextEdit counted in number of lines.
In the docs I can only see textCursor().position() function which counts it in characters.
I also found the QTextLayout class, with has lineForTextPosition() function, but i am not sure if it is what I am looking for, as according to help it serves purpose of putting text into widgets of various shapes and looks like huge overkill to my purposes.
The solution proposed here might be what you are looking for.