Skip to content
Advertisement

How do I access the value from a QLineEdit?

How do I get and store the value that is written in a QLineEdit as well as close the widget after I click save? I have looked over the PyQt5 documentation and it says the function .text() will give access to the values in a QLineEdit but for some reason the value I keep getting is the default empty string.

JavaScript

Advertisement

Answer

The problem is that you are obtaining the text when the window is being built, so the user cannot interact with the GUI, instead you must obtain the information within clickedSave.

On the other hand, I see that this code can never be executed (which is different from failing) since no QLineEdit has a “ui” attribute in addition to similar errors(typos), so please try to provide a better code for the next time.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement