1 Attachment(s)
Unable to change height of the handle of QSlider
I am trying to design a QSlider where I need to vary the height of the slider handle based on certain parameters. This is what I have so far:
Code:
fScrollbar->setGeometry(280,5,10,400);
fScrollbar->setMinimum(5);
fScrollbar->setMaximum(50);
fScrollbar->setTracking(true);
fScrollbar->setStyleSheet("QSlider::handle:vertical { width: 190px; background: black; }");
This is not working as expected, the handle still defaults to a small height which is not changing. This is what which is appearing:
Attachment 11470
How do I make it work?
Re: Unable to change height of the handle of QSlider
Surely you want to change the height of the vertical slider handle, not the width.
Re: Unable to change height of the handle of QSlider
Sorry, my bad. Yes, I am changing the height of the handle for vertical scrollbar. I was experimenting with horizontal scrollbar as well, I posted that code by mistake. Same result in both cases.
Re: Unable to change height of the handle of QSlider
My guess is that the height of a vertical slider handle is tightly controlled by the style plugin or even by the slider itself since it is also used as the indicator how long the scrollable range is.
Cheers,
_
Re: Unable to change height of the handle of QSlider
That makes sense. I thought as much. But I found of plenty of websites where it says that this is the way the height of te handle can be varied, so I thought perhaps I am doing something wrong.
Re: Unable to change height of the handle of QSlider
It is also possible that to customise a part of QSlider you must customise some other parts or all of it. The examples always seem to customise the groove and handle together:
http://doc.qt.io/qt-4.8/stylesheet-e...mizing-qslider
Re: Unable to change height of the handle of QSlider
Yep, that is possible. Will try it out. Thanks!