With
myQLineEdit.textChanged.connect(
lambda: myQLabel.setStyleSheet("QLabel { color: green}"))
I can change the text color while I'm typing. How can I change the text color if the QLineEdit is blank?
The textChanged
signal sends the text as a parameter, so you can use that to switch between colours:
myQLineEdit.textChanged.connect(lambda text: myQLabel.setStyleSheet(
"QLabel { color: %s}" % ('green' if text else 'red')))