Heating using solar panels is not free because generally speaking it takes higher pump speeds and/or higher head (pressure) to use solar heating and that uses more electricity. Nevertheless, they are usually a heck of a lot less expensive than gas heating. Heat pumps in some situations might be close if one accounts for the pump electricity cost difference. I know that in my own pool, solar heating is far, far less expensive than gas heating and that's even with extraordinarily high marginal electricity rates of 40 cents per kilowatt-hour vs. still high but not extraordinary marginal gas rates of $1.40 per Therm. When I am not running solar, I can run my Pentair IntelliFlo variable speed/flow pump at 26 GPM using 275 Watts, but when I am running solar through 12 panels with very long runs on a 1-story roof at 48 GPM it uses 1500 Watts.

It would be very interesting to do a full analysis of solar vs. heat pump taking into account the pump electricity costs assuming a variable speed/flow pump (or possibly a 2-speed pump). I haven't seen anyone do that thoroughly.