Python Forum

Full Version: Save User Input From LineEdit Box To Variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have an input box for user to type their username.

I want that user input saved as a variable.

Here's what I have so far:
self.inputUsername = QtWidgets.QLineEdit(self.centralwidget)
        self.inputUsername.setGeometry(QtCore.QRect(10, 30, 151, 20))
        self.inputUsername.setClearButtonEnabled(True)
        self.inputUsername.setObjectName("inputUsername")
I'm still not sure if TEXTCHANGED is the right function I want...
self.inputUsername.textChanged.connect(self.Username)
Then call it:
def Username(self):
        username = self.inputUsername.text()
I've tried 100 different ways to set the variable, replacing textchanged with textset, 30 different things on stackoverflow. Nothing works Cry

The fact that this seems to basic and I've spend 8 hours on it is killing me
(Nov-22-2017, 08:45 AM)Larz60+ Wrote: [ -> ]tried google?
https://stackoverflow.com/questions/2595...variable-c

Edit:
I got this working by playing around in Qt Designer:

self.lineEdit.textChanged['QString'].connect(self.lineEdit_2.setText)


It sets the user entered text from 1 input box to another...

As far as saving from the input box to a string / variable, still no luck.