In the first instance, you should ensure you aren't echoing the password to the screen. However, ensuring the QLineEdit never stores the full password is probably not possible securely.
You could override the keystroke commands, and encrypt each incoming character. But per character encryption is not really done nowdays, at least in the form A=E
or what have you.
You could do progressive hashes of the string as additional letters come in, but this means a user has 1 attempt to enter their password, as they can't backspace. Any mistake, such as a slipped finger, e.g entering g
instead of f
would mean needing to erase the whole password and start again - not a very friendly UI.
With regards to your worry of someone editing your code, and then capturing the password between the user entering it, and it being sent off, your being paranoid here. To a certain extent once you've sent of your code, you have little control over it. You could distribute the code with an appropriate MD5 hash for the relevant parts and you can check at run time to make sure the code hasn't been altered.
Even then, if someone has the ability to inject arbitrary code into your program then you have bigger problems. I'm not saying your program is insecure, but if someone malicious has access to a computer with the code, they could just as easily insert a hardware or software keylogger rendering all of your attempts moot.
Write your code as secure as possible, accept that at somepoint the password will be in plaintext somewhere and encode it at the first available opportunity. eg:
import mySecureLibrary
password = mySecureLibrary.saltAndHash(self.ui.passwordField.text())
self.ui.passwordField.setText("HAHA, no password for you")