Try the following:
@
import sip
sip.setapi('QVariant',2)
sip.setapi('QString',2)
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class ScrollBar(QScrollBar):
def init(self, parent=None, **kwargs):
QScrollBar.init(self, parent, **kwargs)
self.setStyleSheet("""
QScrollBar:horizontal {
border: none;
background: none;
height: 26px;
margin: 0px 26px 0 26px;
}
QScrollBar::handle:horizontal {
background: lightgray;
min-width: 26px;
}
QScrollBar::add-line:horizontal {
background: none;
width: 26px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal {
background: none;
width: 26px;
subcontrol-position: top left;
subcontrol-origin: margin;
position: absolute;
}
QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {
width: 26px;
height: 26px;
background: none;
image: url('./glass.png');
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
background: none;
}
/* VERTICAL */
QScrollBar:vertical {
border: none;
background: none;
width: 26px;
margin: 26px 0 26px 0;
}
QScrollBar::handle:vertical {
background: lightgray;
min-height: 26px;
}
QScrollBar::add-line:vertical {
background: none;
height: 26px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
background: none;
height: 26px;
subcontrol-position: top left;
subcontrol-origin: margin;
position: absolute;
}
QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical {
width: 26px;
height: 26px;
background: none;
image: url('./glass.png');
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
""")
class Widget(QWidget):
def init(self, parent=None, **kwargs):
QWidget.init(self, parent, **kwargs)
self.setWindowTitle("Custom Scroll Bar Example")
l=QVBoxLayout(self)
self._scrollArea=QScrollArea(self)
self._scrollArea.setVerticalScrollBar(ScrollBar(self))
self._scrollArea.setHorizontalScrollBar(ScrollBar(self))
w=QWidget(self)
ll=QGridLayout(w)
for i in xrange(20):
for j in xrange(10):
ll.addWidget(
QPushButton(
"Button ({0},{1})".format(i,j),
self
), i, j
)
self._scrollArea.setWidget(w)
l.addWidget(self._scrollArea)
self.resize(250,400)
if name=="main":
from sys import argv, exit
a=QApplication(argv)
w=Widget()
w.show()
w.raise_()
exit(a.exec_())
@
It should look something like:
!http://s24.postimg.org/rhcr4uzs5/Screen_Shot_2014_05_06_at_12_21_29.png(Custom Scroll Bar Example Screenshot)!
You'll just have to find an image to substitute for my 'glass.png'.
Hope this helps ;o)