PDA

View Full Version : Pyqt QScrollArea not scrolling



elanari
25th July 2011, 09:59
I want to put some elements of my UI in a scroll area as there can be a lot of them. I tried the following peice of code, but the area just keeps growing as I put more elements on it.

In the first part I set up a scroll area, a widget and a layout. I apply the layout to the widget and I set the widget to the scrollarea. Then I fill in my layout in an external function. The button under all of it allows to fill more elements in the layout.


scrollRow = QtGui.QScrollArea()
scrollRow.setMaximumSize(600, 400)
self.rowAssetWidget = QtGui.QWidget()
self.rowAssetLayout = QtGui.QGridLayout()
self.rowAssetLayout.setSpacing(20)
self.rowAssetWidget.setLayout(self.rowAssetLayout)
scrollRow.setWidget(self.rowAssetWidget)
#self.mainLayout.addLayout(self.rowAssetLayout, 2, 0)
self.mainLayout.addWidget(self.rowAssetWidget, 2, 0)
self.assetRow()

self.addAssetRowBtn = QtGui.QPushButton("+")
self.addAssetRowBtn.setFixedSize(20, 20)
self.mainLayout.addWidget(self.addAssetRowBtn, 3, 0)
self.connect(self.addAssetRowBtn, QtCore.SIGNAL("clicked()"), self.addAssetRow)

My elements appear fine, but it is not scrolling. Any idea ?