Answer the question
In order to leave comments, you need to log in
Is it possible to find out which element triggered the textChanged signal?
There are several cells that need to be interacted with in the same way. For example, enter a value in a certain range, if you enter it outside the range, some action is performed on the desired cell. As in the code, so that on_text_changedE selects the cell itself, and not prescribe for each separately. Is there a possibility to do this?
self.ui.lineEditE1max.textChanged.connect(self.on_text_changedE)
self.ui.lineEditE1min.textChanged.connect(self.on_text_changedE)
def on_text_changedE(self, text):
if text == "":
pass
elif text == "0":
pass
elif float(text.replace(',', '.')) < 0.9 or float(text.replace(',', '.')) > 1.5:
self.ui.lineEditE1max.setModified(False)
self.ui.pushButton.setEnabled(False)
QtWidgets.QToolTip.showText(QtGui.QCursor.pos(),"Введите значение от 0.9 до 1.5", self.ui.lineEditE1max)
Answer the question
In order to leave comments, you need to log in
in the handler, call sender() of the main class, it returns the object that emitted the signal
def on_text_changedE(self, text):
widget = self.sender() # <- вот то, что испустило сигнал
if text == "":
pass
elif text == "0":
pass
elif float(text.replace(',', '.')) < 0.9 or float(text.replace(',', '.')) > 1.5:
self.ui.lineEditE1max.setModified(False)
self.ui.pushButton.setEnabled(False)
QtWidgets.QToolTip.showText(QtGui.QCursor.pos(),"Введите значение от 0.9 до 1.5", self.ui.lineEditE1max)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question