How to remove value listeners from a Slider?

So I’ve got a Listbox, and it has custom row components that contain sliders.
And those sliders’ values are respectively bound to other stuff using slider.getValueObject().referTo(otherWidget->getValueObject()); – the point being is that they have a value listener added.

Since the listbox recycles the row components as you scroll, and as old row’s components get updated with new row’s data, I need to remove the value listeners associated with the old row’s data.

I can’t figure out how to do this! The only Value::Listener in the Slider class (the Slider::Pimpl) isn’t exposed publicly, so I can’t grab it and call widget->getValueObject().removeListener(slider->getPimpl());

What’s the recommended solution?

Thank you all.

The Slider has it’s own Value to which it listens so you don’t need to remove the listener. Simply re-refer the value object to something else or nothing, like this:

slider.getValueObject().referTo ({});
1 Like