In theory, yes the Q35 can support the Q9650, but for the HP OEM computer, if they did not provide the BIOS, then who knows until you try it on.
The hd5450 drew less power, but after I double check you may use the single slot low profile type r7 240 with the 240W PSU. Keep in mind I did it on paper, so I am sorry I don't know you can or can not use it with that MB/PSU.
And you may try 1) update the MB BIOS, if the MB does not have the newer one. 2) Boot into the BIOS to see you can find the section to disable "Secure Boot", enable "Legacy Boot" or not, because in case if the PC doesn't boot when you install the r7 240, if you use win8 or win10.
https://support.hp.com/us-en/document/c03653200 3) If you can't find that feature, just forget about add the r7 240.