Admin
RT,我使用的QSS如下:
QScrollBar:vertical {
/* scroll bar */
border: none;
background: transparent;
width: 15px;
padding: 2px;
}
QScrollBar::handle:vertical {
/* scroll button */
border: none;
background: #636363;
border-radius: 2px;
}
QScrollBar::add-line:vertical {
/* top button */
background: transparent;
}
QScrollBar::sub-line:vertical {
/* bottom button */
background: transparent;
}
在Linux平台下一切正常,但是在Windows平台下不是预期效果,如下图:
经搜索,在下面帖子出现了相似描述, 但是API太老已经废弃:
https://forum.qt.io/topic/961/style-the-scrollbar-of-qlistview/13
在下面链接找到新的API:
https://doc.qt.io/qt-5/sourcebreaks.html#changes-to-qstyle
https://doc.qt.io/qt-5/qstylefactory.html#create
# keys = QStyleFactory.keys()
self.setStyle(QStyleFactory.create('Fusion'))