I would like to able to drag the first or second splitters in the code below to the right and have the widget inside the scroll area push out to the right when the width limit of each widget is reached (like when the window is resized smaller and the widget inside the scroll area is progressively hidden). Currently if I drag a splitter to the right, the scrolling stops when the width limit of the widgets is reached. Any idea how to do this.
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import QScrollArea
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
hbox = QtGui.QHBoxLayout(self)
first = QtGui.QFrame(self)
first.setFrameShape(QtGui.QFrame.StyledPanel)
first.setMinimumWidth(50)
second = QtGui.QFrame(self)
second.setFrameShape(QtGui.QFrame.StyledPanel)
second.setMinimumWidth(50)
third = QtGui.QFrame(self)
third.setFrameShape(QtGui.QFrame.StyledPanel)
third.setMinimumWidth(50)
splitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
splitter.addWidget(first)
splitter.addWidget(second)
splitter.addWidget(third)
scrollArea = QScrollArea()
scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
scrollArea.setWidgetResizable(True)
scrollArea.setWidget(splitter)
hbox.addWidget(scrollArea)
self.setLayout(hbox)
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('QtGui.QSplitter')
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()