除非编辑字段不为空,否则如何禁用按钮?

eco*_*eco 1 python qt pyside qlineedit qpushbutton

我有一个 QLineEdit 字段和一个 QPushButton。只要 QLineEdit 为空,就应该禁用该按钮。

怎么做?

Jac*_* Wu 5

well, i'll just conclude what they said in the comments, some code like

self.btnButton.setDisable(True)
self.leInput.textChanged.connect(self.disableButton)
def disableButton(self):
    if len(self.leInput.text()) > 0:
        self.btnButton.setDisable(False)
Run Code Online (Sandbox Code Playgroud)

and yes, the signals / function names are obvious, you need to check more on the docs / tutor