superqt
superqt copied to clipboard
QLabeledRangeSlider no labels after setValue() int the second time
update values the second time removes all labels When I create my_slider QLabeledRangeSlider object then set the values with my_slider.setValue(mylist_1) every thing works fine but when I set a new dataset with my_slider.setValue(mylist_2), only handles updated all labels disappear.
To Reproduce Steps to reproduce the behavior:
- create a QWidget to host the QLabeledRangeSlider slider
- create a QLabeledRangeSlider object as child then set its value with .setValue() method
- create a QPushButton to set new values then connect its signal clicked to an update method
- see error: the slider updates with no label at each handle, only range label displayed.
example code
import sys, os
from PySide6.QtWidgets import QApplication, QWidget, QPushButton
from PySide6.QtCore import Qt
from superqt import QLabeledRangeSlider
class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
sl = tuple([0, 90, 210, 259, 374])
self.main_slider = QLabeledRangeSlider(parent=self)
self.main_slider.setOrientation(Qt.Horizontal)
width = self.geometry().width()
self.main_slider.setMinimumWidth(width)
self.main_slider.setRange(sl[0], sl[-1])
self.main_slider.setValue(tuple(sl))
btn = QPushButton(self)
btn.clicked.connect(self.update)
def update(self):
sl = tuple([1261, 1281, 1334, 1365, 1697, 1871, 1916])
self.main_slider.setRange(sl[0], sl[-1])
self.main_slider.setValue(sl)
if __name__ == '__main__':
app = QApplication([])
win = Window()
win.show()
sys.exit(app.exec())
Expected behavior expected labels .at each handle.
Screenshots

Desktop (please complete the following information):
- Windows 10
- PySide6
- Python 3.7.13, conda 4.10.1
FOUND: one have to addd this line after setValue():
my_slider.setHandleLabelPosition(1)
FOUND: one have to addd this line after
setValue():
my_slider.setHandleLabelPosition(1)
That is a weired behavior. I would think this is a bug.
sorry for the delay here... And thank you very much @looninho for the super useful example. This is fixed in #123