Important: Please read the Qt Code of Conduct -

Using background picture for QScrollBar::handle

  • Hello
    I'm creating a list that is supposed to have a styled scrolling handle. I have a static picture which I want to apply to the handle, meaning it should not be stretched, nor repeated. I've tried to apply the following style sheet without success:

    @*{background-image: url(:/middle/03_Middle/ksw_dc_middle_bgr.png); border:0px;}
    QScrollBar:vertical { background: black; width: 10px; margin: 0px 0px 0px 0px;}
    QScrollBar::handle:vertical {background-image: url(:/list/05_List_items/ksw_dc_list_scroll_bgr.png); max-height: 20px;}@

    The result is as wanted, except that the picture is tiled upon itself. With other words, the max height doesn't have any effect, instead the handled is streched according to the amount of items in the list. How can I prevent this and use it, kinda like a QSlider? (using an actual QSlider is unfortunately not an option at this point) Thank you!

    Best regards

  • Is this even possible, and if not, is there a way to create a similar effect or to somehow reasonably scale the image?

Log in to reply