How to disable a QLineEdit in Pyqt?

3

How do I disable a QLineEdit in Pyqt5?

Example:

  inputUserName = QLineEdit(self)

I would like to leave it disabled, same as Html , when we use the disabled attribute. Is it possible?

    
asked by anonymous 26.07.2018 / 17:56

2 answers

2

You can use the setDisabled method of QWidget . QLineEdit inherits from this class.

inputUserName.setDisabled(True)
    
26.07.2018 / 18:34
4

Complementing the response from LINQ :

You can also use the setEnabled ("enabled"="enabled") method:

inputUserName.setEnabled(False)  #desabilita o controle

inputUserName.setEnabled(True)   #habilita o controle

Obviously the boolean works in the inverse of setDisabled .

    
27.07.2018 / 22:13