pyapp-kit / superqt

Missing widgets and components for Qt-python
https://pyapp-kit.github.io/superqt/
BSD 3-Clause "New" or "Revised" License
210 stars 37 forks source link

Customize labeldoublerangeslider handle values with qss, is it possible? #229

Closed maidenloko closed 10 months ago

maidenloko commented 10 months ago

Hello! Thanks for the great work! I'm developing an app for editing thermal images, and would like to know of it is possible to access and customize the handle values using qss. I had to add a padding to the groove and the edge labels lost alignment with slider. But more importantly I would like to customize the handle values with qss once they represent the min and max temperature and they clip the image for thresholding. Is there a waynto access them is qss? Thanks in advance.

Ivan.

tlambert03 commented 10 months ago

All slider labels are instances of superqt.sliders._labeled.SliderLabel, so you could target them using SliderLabel:

SliderLabel {
    color: red;
}

depending on your needs, you might want to be more specific by giving one of your sliders an object name:

my_slider = QLabeledDoubleRangeSlider()
my_slider.setObjectName("my_slider")
my_slider.setStyleSheet(
    """
    QLabeledDoubleRangeSlider#my_slider SliderLabel{
        color: blue;
    }
    """
)

let me know if you need ideas for more specificity than that.

IvanDesuo commented 10 months ago

awesome! I'm not intending nothing too fancy, maybe a background and border around the number and hover effect, I have been trying some proprieties, such as border and background without success, I would assume it doesn't support these? I have been working on an app for editing thermal images, so it is really not necessary, but a cool touch. Thank you very much. This is how it looks now:

image

tlambert03 commented 10 months ago

ultimately, it's just a QSpinBox, so any styling that you can do with a spin box applies to the label as well: https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qspinbox

IvanDesuo commented 10 months ago

Thanks a lot!! Got involved with some other things will back to customization. I dont know how to set the thread as finalized, but I consider it answered and solved.