Quote:
he/she can easily go to WiFi settings of the phone and share QR code of that credentials to others. How my app or I can secure this password? Is it not a security threat?
You can't: it's a system wide function and by design. If they install the appropriate app they get the password as a QR code. You can't stop that, with or without your app.
The solution is to regularly change your WiFi password ... which is a real PITA nowadays, I'd need to change at least 10 devices to keep them online!