PDA

View Full Version : Problem styling QScrollBar::handle



kerchen
9th November 2012, 18:06
I'm trying to customize a scroll bar's appearance by changing its stylesheet and I've been able to achieve nearly everything I want to do except for changing the 'handle' sub-control. If I do anything with the handle, something ends up working incorrectly elsewhere in the scroll bar. For example, if I simply add this to the bottom of my stylesheet:


QScrollBar::handle {
background: rgb(255,255,255);
}

the resulting scroll bar has a white handle but it allows the handle to be dragged over the full extent of the scroll bar control, including over the add-line and sub-line controls! Other changes cause other strange behaviors, such as the add-line and sub-line controls being fully obscured by the add-page and sub-page areas, etc.

Here is my stylesheet in its current state; it works exactly as I want except for the handle styling:


QScrollBar:vertical {
background: rgb(64, 64, 64);
min-height: 50px;
width: 50px;
}


QScrollBar::sub-line {
border: 1px solid white;
image: url(:/Common/arrow_triangle_bright_up.png);
}
QScrollBar::sub-line:pressed {
image: url(:/Common/arrow_triangle_black_up.png);
background: rgb(255,255,255);
}

QScrollBar::add-line {
border: 1px solid white;
image: url(:/Common/arrow_triangle_bright_down.png);
}

QScrollBar::add-line:pressed {
image: url(:/Common/arrow_triangle_black_down.png);
background: rgb(255,255,255);
}

QScrollBar::add-page:enabled, QScrollBar::sub-page:enabled {
background: none;
}


Is there something wrong with my stylesheet and it just happens to work if I don't mess with handle styles?

I'm doing this in Qt 4.5.0 (yeah, I know this is a fairly old version) under Win7/MSVC2005 (also kind of long in the tooth).
Has anyone encountered this problem? If so, how did you resolve it?

Thanks!