本文主要讲述如何通过 qss 自定义滚动条 QScrollBar ,我们先以实现一个扁平化的滚动条为例,效果如下图所示。 扁平化滚动条实现 12345678910111213141516171819202122232425262728293031323334 QScrollBar:vertical { width: 8px; background: #f0f0f0;}QScrollBar:horizontal { height: 8px; background: #f0f0f0;}QScrollBar::handle:vertical { background: #cdcdcd; min-height: 30px;}QScrollBar::handle:horizontal { background: #cdcdcd; min-width: 30px;}QScrollBar::handle:vertical:hover,QScrollBar::handle:horizontal:hover { background: #a6a6a6;}QScrollBar::sub-line:vertical, QScrollBar::add-line:vertical,QScrollBar::sub-line:horizontal, QScrollBar::add-line:horizontal