This code should be quite self explanatory. And this is how you can use it. Of course you should never have your private key in your code.
With credits for ChatGPT which after several promts still coulnd’t make 100% functional code. But it gave me the broad idea of the code I could use. It’s simple, It’s elegant. And somehow it isn’t in the Qt codebase for as fas as I could find.