I have a QLineEdit and a QSlider in which it interacts with each other.
Eg. If I set a value in the QLineEdit, the slider will be updated, or if I slide the slider a
After much findings, this works for me:
# Connection Signals
# When user tweaks using the slider
self.slider.valueChanged[int].connect(self.update_spinbox)
# When user modify via the spinbox
self.spinbox_value.editingFinished.connect(self.update_slider)
# Functions for each modication made towards slider and spinbox
def update_slider(self):
# spinbox_value uses float/ doubles type
# '*100' is used to convert it into integer as QSlider
# only register integer type
spinbox_value = self.spinbox_value.value() * 100
self.slider.setSliderPosition(spinbox_value)
def update_spinbox(self, value):
# QSlider only uses integer type
# Need to convert the value from integer into float
# and divides it by 100
self.spinbox_value.setValue(float(value) / 100)