It depends on how the text in the editor is stored, but I am going to assume you are using 1 giant buffer. In that case, you would loop through the characters and every time you hit a newline character you would check to see if you reached the line requested by the user, or if there is no more characters in the buffer.
What I mean is that no one is going to do your work for you. So if you show us something you've done and ask "How do I go about adding feature X to it," someone might help you; but if--as you did--you say "I want feature X in my program; pleae do it for me," you're not going to get very far.
I am not familiar with Qt, but I am guessing that there is some function inherited from GPlainTextEdit that will allow you to access the text in the editor. You need to look up some documentation for a function like that. Also you should put the #endif at the end of the file, not just after the includes.