Code to return a particular number of line along with the text from a document in qt

We are trying to code a program that will check for certain rules and find out violations of those rules from a text file. What we need help is with how to find in what line number the rule has been violated. How to return the line number of that particular line in which the rule has been violated, along with that text ?

@Joel-George
i don't know how anybody here should help you, since this heavily depends on your implementation of your rule-violation-checking?!
You should be more precise with your question regarding Qt mechanics/classes i guess.