QScrollBar Stylesheet not working with Qt 5.3.1
-
Hello,
I found a strange behavior of my styled scrollbar under Qt 5.3.1. It seems that the stylesheet for the QScrollBar is not working. It always shows the default windows-styled scrollbar. I also checked the example stylesheet for the QScrollBar from the Qt 5 documentation, no success!
All my other stylesheets are working with 5.3.1 its just the stylesheet for QScrollBars that don't work for me!If I compile the same code with Qt 5.2.1 everything works fine.
Is this a bug in Qt 5.3.1? Does anyone else have this problem?
Thanks,
JK_IKA -
Works ok for me. How (and on what) do you set your stylesheet?
-
I inherited from QTableView and then set the following stylesheet with setStyleSheet()
@QString QtExampleScrollBarStylesheet = "QScrollBar:horizontal {"
"border: 2px solid grey;"
"background: #32CC99;"
"height: 15px;"
"margin: 0px 20px 0 20px;"
"}"
"QScrollBar::handle:horizontal {"
"background: white;"
"min-width: 20px;"
"}"
"QScrollBar::add-line:horizontal {"
"border: 2px solid grey;"
"background: #32CC99;"
"width: 20px;"
"subcontrol-position: right;"
"subcontrol-origin: margin;"
"}""QScrollBar::sub-line:horizontal {"
"border: 2px solid grey;"
"background: #32CC99;"
"width: 20px;"
"subcontrol-position: left;"
"subcontrol-origin: margin;"
"}""QScrollBar:vertical {"
"border: 2px solid grey;"
"background: #32CC99;"
"width: 15px;"
"margin: 22px 0 22px 0;"
"}"
"QScrollBar::handle:vertical {"
"background: white;"
"min-height: 20px;"
"}"
"QScrollBar::add-line:vertical {"
"border: 2px solid grey;"
"background: #32CC99;"
"height: 20px;"
"subcontrol-position: bottom;"
"subcontrol-origin: margin;"
"}""QScrollBar::sub-line:vertical {" "border: 2px solid grey;" "background: #32CC99;" "height: 20px;" "subcontrol-position: top;" "subcontrol-origin: margin;" "}" "QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {" "border: 2px solid grey;" "width: 3px;" "height: 3px;" "background: white;" "}" "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {" "background: none;" "}"
;@
-
That works for me. Maybe you mixed some library files versions?
-
No, don't think so, just Qt 5.3.1 installed on the laptop, Qt 5.2.1 runs on my PC (both Win7). All other stylesheets are working only the QScrollBox doesn't.
I tested it on a linux machine, too, same result.
There is also no compile warning!
Can it somehow come from the compiler? I'm using msvc2012 on PC and on laptop and linux mingw? -
I've tested it with VS2013 and MinGW 4.8.2 on a Windows 8.1 machine. Both work ok. I don't see how compiler could matter.
Is it the same if you run a minimal example or is it just in your app? Try this
@QApplication a(argc, argv);
QScrollArea w;
w.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
w.setStyleSheet(" ... ");
w.show();
return a.exec();@