Breaking Refactor: Make GenericSliders inherit QWidget
rather than QSlider
or QAbstractSlider
#249
Labels
bug
Something isn't working
The original design of all the Range sliders here (which all subclass
sliders._generic_slider._GenericSlider
) was to make them behave as much like drop-in replacements forQSlider
as possible. I wanted them all to passisinstance(obj, QSlider)
checks, and inasmuch as possible, inherit all of the behaviors ofQSlider
.However, that has proven difficult to maintain, and the biggest issue relates to signals (particularly with PySide). In most of the slider variants the
value()
(and thereforevalueChanged
signal) is of a different type than the superclass.QDoubleSlider
, of course, has avalue()
of typefloat
, whileQRangeSlider
has a value type oftuple[int, ...]
.We do some "unsavory" patching of the signal instances, on the object instances themselves, like here and here. And, for the most part it works, but requires very ugly hacks (#51). But really, it doesn't work well... and it's just a matter of time before it breaks again. I already get misc bus errors and segfaults during tests on pyside6 with the current strategy (thought pyqt6 is fine).
So, the two main options that I can see are:
QAbstractSlider
, since it already has the signal names we want to use, and changing the value type of signals has proven to be a bad idea. A refactor like this would mean either using composition, or re-implementing basically all of the methods in the C implementation of QAbstractSlider to make these objects essentially duck-QSliders (many of those are reimplemented anyway as is). They would no longer passisinstance()
, but they would still be mostly drop-in replacements.QDoubleSlider.valueChanged
would beQDoubleSlider.floatValueChanged
or something like that,rangeChanged
would have to befloatRangeChanged
... andQRangeSlider.valueChanged
might beQRangeSlider.valuesChanged
, etc... This breaks a lot of existing code, but might be cleaner to implement.this doesn't have to happen soon, but it's a bit of a ticking time bomb. @Czaki and @jni, just a heads up if you have any opinions.
The text was updated successfully, but these errors were encountered: