'Qui' and 'que' are relative pronouns, used to avoid repetition.
Look at the following sentence:
La petite fille joue avec le chat. Le chat appartient à ma grand-mère.
It sounds clunky. We can make it better by using a relative pronoun:
La petite fille joue avec le chat qui appartient à ma grand-mère.
The noun that we wish not to repeat can be replaced by the pronouns 'qui' or 'que'. So when do we use which? Our choice of pronoun depends on the function of the noun within the clause. In the example above, the cat is the subject of the clause- it does the belonging, it performs the verb 'appartenir'. When the noun replaced by the relative pronoun is the subject, we use 'qui'.
So when do we use 'que'? Let's look at the following example:
La petite fille joue avec le chat. Je regarde le chat.
This becomes:
La petite fille joue avec le chat que je regarde.
Here, the cat does not perform the verb 'regarder', it does not do the watching- it is not the subject. The verb is performed by another subject- je. I am watching the cat. The cat is the direct object- something is done to it. It is being watched. When the noun replaced by a relative pronoun is the direct object of the verb, we use 'que'.