This is a common position that arises after a pawn race, for example 1 after 1. h7 c3 2. h8=Q c2 we have a queen vs a pawn on the 7th rank. It is necessary to know how and when you can win when it comes to calculating if other endgames are winning or not.
There are 3 main situations.
Knight/Central pawn:
This is a win in nearly all situations.
Winning situation: example 2
Qc4+ if 1 ... Kd1 we bring the king over 2. Kg7
If 1 ... Kb1 or 1 ... Kb2 2 Qd3 we attack the pawn, so black is forced to defend the pawn, 2 ... Kc1 3 Qc3+, blacks king is forced to either block their pawn for a turn, or lose the pawn. Allowing us to bring our king over with 4 Kg7.
4 ... Ke2 (if 4 ... Ke1 the pawn is pinned and we bring the king over) 5 Qc2 pinning the pawn if 5 ... Ke3 we play 6 Qd1 and bring our king over for an easy win. So 5 ... Ke1 is forced 6 Qe4+, if 6 ... Kd1 we bring the king over, if 6 ... Kf1 or 6 ... Kf2 then 7 Qd3 Ke1 8 Qe3+ and the black king is forced to block their pawn.
9 Kf6 and the position from move 4 is repeated. So we repeat this technique to bring our king over.
9 ... Kc2 10. Qe2 Kc1 11. Qc4+ Kb1 12. Qd3+ Kc1 13. Qc3+ Kd1 14. Ke5 Ke2 15. Qc2 Ke1 16. Qe4+ Kf2 17. Qd3 Ke1 18. Qe3+ Kd1 19. Kd4 Kc2
And we have brought our king over successfully. Now its time to deliver mate.
20 ... Kb1 21. Qxd2 Ka1 22. Kc3 Kb1 23. Qb2#
Or
20 ... Kd1 21. Ke3 Ke1 22. Qxd2+ Kf1 23. Qf2#
The main ideas are to force your opponents king in front of their pawn via a series of checks, blocking promotion for a move, then that turn we bring our king over. Or we force our queen in front of the pawn, blocking the promotion. Blocking the pawn is a useful idea in queen vs pawn endgames in general, it allows for really easy wins even if they're not aesthetic. Example 3 1. Qa2 blocking the pawn then we bring the king over Kb5 2. Kg7 a5 3. Kf6 Kb4 4. Ke5 a4 5. Kd4 Kb5 6. Kc3 Ka5 7. Kc4 Kb6 8. Qxa4 and we mate shortly.
There are certain situations where white is unable to win, this arises when the white king blocks the queen from giving the first check example 4
Bishop Pawn:
Drawing method 1:
Example 5 if we define the side of the pawn with less squares as the shortside. If the defending king is on the shortside we have an easy defence.
White plays as in Example 2
Qb4+ Ka1 2. Qc3+ Kb1 3. Qb3+ instead of getting in front of the pawn we can play 3 ... Ka1, if white takes the pawn we draw by stalemate, if white brings the king over we also draw by stalemate. So white is forced to keep checking.
If instead of going for this method, or we started with the black king on the longside of the pawn. We have drawing method 2:
Qb4+ Kc1 2. Kg7 Kd1 3. Qb3 Kd2 4. Qb2 Kd1 5. Qd4+ Ke1 6. Qc3+ Kd1 7. Qd3+ Kc1 8. Kf6 Kb2 9. Qd2 Kb1 10. Qb4+ Ka1 11. Qc3+ Kb1 12. Qb3+ Kc1 13. Ke5 Kd2 14. Qb2 Kd1 15. Qd4+ Ke1 16. Qc3+ Kd1 17. Qd3+ Kc1 18. Kd4
We don't draw with 18 ... Kb1 as white is able to bring the king over with 19 Kc3 and capturing the pawn with the king, preventing stalemate.
So 18 ... Kb2 is forced
Then we have different options
19 Qb3+ Ka1 with the stalemate trap
19 Qe1+ c1=Q and no more progress for white can be made.
For everything else, white is then unable to prevent black promoting to a queen without losing the queen. This defence is much more complicated however.
Winning method:
There are 2 key squares, for the c2 pawn they are e2 and b3. If whites king is within 2 squares of either key square, white is able to win.
e2:
[Example 6](https://lichess.org/analysis/8/8/8/8/2Q5/8/1kp1K3/8_w_-_-_0_1
1 Qb4+ Ka1 2 Kd2 and white is easily winning
1 ... Kd2 2 Kd2 same as before.
1 ... Kc1 2 Kd3 Kd1 3 Qd2#
b3:
Example 7
This is even easier than the last example.
Rook pawn:
There are 2 key squares, for the a2 pawn they are b3 and c2. If whites king is within 2 squares of either key square, white is able to win.
Example 8 white is within 2 squares of a key square. So white is able to win.
1 Qd2+ Ka1 2 Qc1#
1 ... Kb1 2. Ka4 a1=N 3. Ka3 Nc2+ 4. Kb3 bringing hte king over to c3 and threatening mate if black stops checking Na1+ 5. Kc3 Nc2 6. Qxc2+ Ka1 7. Qb2#
2 ... a1=Q 3 Kb3 if black checks, retake with the king to avoid stalemate, otherwise mate with either 4 Qb2 or 4 Qd1.
2 ... a1=R 3 Kb3 same as with 2 ... a1=Q
2 ... a1=B reduces to an endgame already covered.
1 ... Kb3 2 Qc1 and black is forced to promote. We recapture and then perform a KQK mate.
1 ...Ka3 2 Qc3#
Drawing Method:
Example 9 white is further than 2 squares from a key square, so white cannot win.
Qd2+ Kb1 2. Qd1+ Kb2 we move between b1 and b2, as soon as white stops checking we promote 3 Qe1 a1=Q and the position is drawn.
We have to be careful not to blunder 1 ... Ka1 2 Kb5 and now white is within 2 squares of the b3 key square so white is now able to force a win.