Reputation: 870
Hello World, I am working on a text editor in Qt c++ and I would like to know how to get the current row and column of a QPlainTextEdit. The reason I need it is to put it on the status bar of my app and I have no IDEA on how to do it. Please help me.
Upvotes: 2
Views: 2402
Reputation: 73101
Call the QPlainTextEdit's textCursor() method to get a QTextCursor object representing the current position of the text-editing caret. You can then call blockNumber() to get the current row, and positionInBlock() to get the position within the row (i.e. the column).
You'll probably also want to connect the QPlainTextEdit's cursorPositionChanged() signal to a slot in your program, so that you can update your display as the text-cursor moves around.
Upvotes: 8