PDA

View Full Version : QScrollbar handle stretch problem



Beppe
28th July 2009, 09:44
Hi all,

I'm styling my scrollbar and I have a problem on stretching the scrollbar's handle.

I read this post

http://www.qtcentre.org/forum/f-qt-programming-2/t-qscrollbar-stylesheet-10569.html

and I understand that styling the handle means stretch an image like this:

"The middle parts will be stretched or repeated (depending on your settings) and corners will be applied without any scaling to prevent distortions."

I would like not to stretch the middle part and to strecth, instead, the corners.

Is it possible using QStyleSheet? I have to define my custom style?

Thank you for any suggestion.

Beppe

wysota
28th July 2009, 10:21
I don't think you can do that using stylesheets... I can't think of any possible reason to want to stretch corners, anyway... I'd suggest you implemented your own widget style for the scroll bar and apply it using the proxy style technique.

Beppe
28th July 2009, 15:07
Thank you wysota,

if you say

I can't think of any possible reason to want to stretch corners, anyway...
maybe I don't cope with the problem in the correct way.

I have an image (handle.jpg) applied to the handle of the scrollbar. With StyleSheet I set the handle's minimum size and it works correctly.

When the scrollbar grows, the handle image is stretched but the final effect is awful (see the second image).

my stylesheet code is




QScrollBar::vertical {\
background:lightgray;\
border-color:black;\
border-style:solid;\
width: 50px;\
margin-top:1px;\
margin-bottom:1px;\
}\
\
QScrollBar::handle:vertical,\
QScrollBar::handle:pressed{\
border-image: url(handle.png);\
min-height: 96px; \
} \
\
QScrollBar::add-line:vertical{\
background:none;\
border-width:0px;\
height: 0px;\
width: 0px; \
} \
\
QScrollBar::sub-line:vertical { \
background:none;\
border-width:0px;\
height: 0px;\
width: 0px; \
} \
\
QScrollBar::add-page:vertical, \
QScrollBar::sub-page:vertical {\
background: none;\
}\
\
QScrollBar::add-line:pressed,\
QScrollBar::sub-line:pressed {\
background: none;\
}


Thanks

Beppe

wysota
28th July 2009, 15:50
But stretching corners will not help you in any way.

You should create your own style. Unfortunately QScrollBar doesn't have any special sub-control for the middle part of the handle.

Beppe
30th July 2009, 13:58
OK. Thanks