![]() |
Save User Input From LineEdit Box To Variable - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Save User Input From LineEdit Box To Variable (/thread-6433.html) |
Save User Input From LineEdit Box To Variable - digitalmatic7 - Nov-22-2017 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 ![]() The fact that this seems to basic and I've spend 8 hours on it is killing me RE: Save User Input From LineEdit Box To Variable - Larz60+ - Nov-22-2017 tried google? https://stackoverflow.com/questions/25953927/saving-the-content-of-a-qlineedit-object-into-a-string-variable-c RE: Save User Input From LineEdit Box To Variable - digitalmatic7 - Nov-22-2017 (Nov-22-2017, 08:45 AM)Larz60+ Wrote: tried google? 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. |