You are seeing errors when you use "Program" and "Verify" commands because they are PSoC1 APIs and not to be used for PSoC4. Please refer to the section Command Overview in the PSoC Programmer CLI User Guide to get more information on what APIs are supported for PSoC4.
Since you are reading the hex file in the beginning, you can make use of the PSoC4_ProgramRowFromHex API and provide the row IDs to program the device. You need to call this until all the rows are written which might be something tedious.
Since the end goal is to integrate this into a Qt C++ application, I would recommend making use of PSoC Programmer COM library to write the C++ code for programming the device. You can find the example here: "C:\Program Files (x86)\Cypress\Programmer\Examples\Programming\PSoC4\SWD\Cpp_Ex"
Let me know if you have any further queries.
Thank you Dheeraj for your response. I actually use PSoC4_ProgramRowFromHex to program the chip and it works fine, I just have a really long list of commands in my text file.
I will make an improvment of my code using PSoC Programmer COM library as you suggest when I will be less in a hurry.