Does a driver lose qualifying points if they take a grid penalty for a gearbox or engine change?

The points scored for qualifying are based on the qualifying classification, not grid position. If a driver is penalised for changing engine/gearbox, he does not lose qualification points for it. The driver/team have worked hard to qualify well and deserve the points. Their grid penalty means they will probably end up scoring less points during the race, which should act as suitable punishment (unless they have a great race, in which case they fully deserve the points!).