Check whether a QLineEdit is empty or not

Heads up! You've already completed this tutorial.

Deebalaji asked

I am Newbie to Python and PyQt5.

Just I want to know, How to create a Class/Module to check whether the QLineEdit is empty or not ? and how to import this Module in another Programme/File?

You don't need a class/module to check something as simple as that. PyQt5 Widgets all have their own methods which can be used to get the current state of the widgets. On a QLineEdit you can get the current contents using .text()

Since in Python an empty string "" is falsey and any content is truthy you can just use that value for your conditional, e.g.

python
if lineedit.text():
     # do something if there is content in the line edit.

Hope that helps!

Over 10,000 developers have bought Create GUI Applications with Python & Qt!

To support developers in [[ countryRegion ]] I give a [[ localizedDiscount[couponCode] ]]% discount with the code [[ couponCode ]] — Enjoy!

For [[ activeDiscount.description ]] I'm giving a [[ activeDiscount.discount ]]% discount with the code [[ couponCode ]] — Enjoy!

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak