PDA

View Full Version : QScrollBar changing width on the handle



Scint
12th June 2014, 18:57
I am using a style sheet to customize a QScrollBar for QTextEdit. It is almost looking how I want, but I have run into an odd bug: two different instances of the textedit have different widths on the scrollbar's handle. This doesn't make sense to me because the two textedits have the exact same stylesheet for the scrollbar. Here's an image:

10415

As you can see, the handle is thinner in one, fatter in another. I've tried setting a width for the handle in the stylesheet, but it didn't have an effect.

Does anyone know what could be changing the handle width?

Here's my stylesheet code, for reference:

pCustomScroll->setStyleSheet(
"QScrollBar:vertical {"
"background: rgb(63, 63, 63);"
"width: 22px;"
"margin: 22px 0 22px 0;"
"}"
"QScrollBar::handle:vertical {"
"border: 1px rgb(63, 63, 63);"
"border-radius: 3px;"
"background: rgb( 63, 63, 63 );"
"}"
"QScrollBar::add-line:vertical {"
"background: white;"
"height: 22px;"
"subcontrol-position: bottom;"
"subcontrol-origin: margin;"
"}"
"QScrollBar::sub-line:vertical {"
"background: white;"
"height: 22px;"
"subcontrol-position: top;"
"subcontrol-origin: margin;"
"}"
"QScrollBar::up-arrow:vertical {"
"border-image: url(:/Icons/Resources/Icons/LargeUpArrow.png);"
"}"
"QScrollBar::down-arrow:vertical {"
"border-image: url(:/Icons/Resources/Icons/LargeDnArrow.png);"
"}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
"background: white;"
"}" );

nernst
13th June 2014, 08:31
Hi,

could it be, that the width of your QTextEdit with the smaller scrollBar is smaller than the width of the other QtextEdit? Maybe it has something to do with the sizePolicy?