A scroll bar is a control that enables the user to access parts of a document that is larger than the widget used to display it. It provides a visual indication of the user’s current position within the document and the amount of the document that is visible. Scroll bars are usually equipped with other controls that enable more accurate navigation. Qt displays scroll bars in a way that is appropriate for each platform.
可以用setVerticalScrollBarPolicy设置滚动条的显示方式,包括一直显示、一直隐藏、需要时显示三种,以下是我设置的样式
ScrollBarTable->setStyleSheet( "QScrollBar:vertical {margin: 30px 0px 30px 0px;background-color: #F0F1EF; border: 0px; width: 30px;}\
.QScrollBar::handle:vertical {background-color: #bbbbbb; width: 30px; border-radius: 7px; }\
.QScrollBar::handle:vertical:hover {background-color: #9B9B9B; width: 30px; border-radius: 7px; }\
.QScrollBar::add-page:vertical {background-color: rgb(240,241,239); }\
.QScrollBar::sub-page:vertical {background-color: rgb(240,241,239); }\
.QScrollBar::up-arrow:vertical { border: 0px; width:30px; height: 30px; border-image: url(:/Icons/up_Arrow.png);}\
.QScrollBar::up-arrow:vertical:pressed { border: 0px; width:30px; height: 30px; border-image: url(:/Icons/up_Arrow_down.png);}\
.QScrollBar::down-arrow:vertical { border: 0px; width:30px; height: 30px; border-image: url(:/Icons/down_Arrow.png); }\
.QScrollBar::down-arrow:vertical:pressed { border: 0px; width:30px; height: 30px; border-image: url(:/Icons/down_Arrow_down.png); }\
.QScrollBar::sub-line:vertical {subcontrol-origin: margin; border: 1px solid rgb(240,241,239); height:30px}\
.QScrollBar::add-line:vertical {subcontrol-origin: margin; border: 1px solid rgb(240,241,239); height:30px}");
效果图为