PDA

View Full Version : Line Number - QTextEdit...???



deepusrp
12th May 2007, 08:40
Hello everyone,

I am using QTextEdit in my application. I want to display the line number at the status bar or on a label below textedit box. How can i get the line number. I have searched through the documentation. They have provided a function to get the total number of lines, i haven't seen a function which will provide us the line number where there is a cursor.

For this i think there are two possibility:

1. To display the line number as we see in editing someproject.ui.h(at the statusbar)

2. To display the line number as in the kwrite(left side)

can anyone please tell me the solution to any one of the possibility. A code snippet is helpful

jpn
12th May 2007, 08:43
The current block number can be retrieved via following methods (since Qt 4.2):

QTextEdit::textCursor()
QTextCursor::blockNumber()

deepusrp
15th May 2007, 16:34
Can any one please provide me a code sample. I dont know what to do with the above said class links.

Please explain me the procedure to get the exact line number in the textedit box where the cursor is present. If the cursor moves up n down, line number should change.

please give me the code, if any one have done that.

Thanks in advance