What would be the appropriate way to update binded-fields without triggering a chain of Changed events?
Considering the following scenario:
Changing StartDate should update Months
Changing EndDate should update Months and ExtraMonths
Changing ExtraDate should update ExtraMonths
Changing Months should update EndDate and ExtraMonths
Changing ExtraMonths should update ExtraDate
The problem is that if for example I edit the EndDate spinbox, it triggers 3 cascading events, which isn’t really necessary.
So right now, I do it like this:
def end_date_changed(self, new_end_date):
self.spinBox_months.blockSignals(True) # disable raising a signal
self.spinBox_months.setValue(Months) # update Months spinbox without updating EndDate and ExtraMonths
self.spinBox_months.blockSignals(False) # re-enable raising signals
self.spinBox_extra_months.blockSignals(True)
self.spinBox_extra_months.setValue(Extra_Months) # update ExtraMonths spinbox without updating ExtraDate
self.spinBox_extra_months.blockSignals(False)
And the same for plenty others like them.
It seems to me like a bad way of doing it. Is there a better way?