自定义qss滚动条样式
QString scrollstyle="QScrollBar:vertical" // 纵向的滚动条样式
"{"
"width:8px;"
"background:transparent;"
"margin:0px,0px,0px,0px;"
"padding-top:0px;"
"padding-bottom:0px;"
"}"
"QScrollBar::handle:vertical" // 可滚动区域样式
"{"
"width:8px;"
"background:rgba(69, 178, 255,90%);"
"border-radius:4px;"
"min-height:20"
"}"
"QScrollBar::handle:vertical:hover" // 触摸或点击滚动条样式
"{"
"width:8px;"
"background:rgba(69, 178, 255,100%);"
" border-radius:4px;"
"min-height:20;"
"}"
"QScrollBar::add-line:vertical"
"{"
"height:0px;width:8px;"
"subcontrol-position:bottom;"
"}"
"QScrollBar::sub-line:vertical"
"{"
"height:0px;width:8px;"
"subcontrol-position:top;"
"}"
"QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical"
"{"
"background:#E8EAEF;" // 滚动条底色
"border-radius:4px;"
"}";
ui->scrollArea->verticalScrollBar()->setStyleSheet(scrollstyle);
效果参考: