QLayouts in a QScrollarea
-
Hello great minds, I am having some challenges using scrollarea. It seems to be confusing me. I am building an app which has various classes (windows), I try inserting scrollarea in some of the Windows but being met with challenges. I want the full Window in one of the classes to be scrollable, but it ends up with only a layout being scrollable whereas there are other layouts in the window.
Now see this code:
<>class app(QWidget):
def init(self):
super().init()
self.setWindowTitle("QLayouts Management")
self.resize(270, 110)grid = QGridLayout()
gbox = QGroupBox()
vbox = QVBoxLayout()
hbox = QHBoxLayout()
scrol = QScrollArea()
secondGrid = QGridLayout()secondGbox = QGroupBox()
self.setLayout(grid)
grid.addWidget(gbox)
grid.addWidget(secondGbox)
scrol.setWidget(gbox)
grid.addWidget(scrol)gbox.setLayout(hbox)
hbox.addLayout(secondGrid)surname = QLabel("Surname:")
surtx = QLineEdit()
other = QLabel("Othernames)
othertx = QLineEdit()secondGrid.addWidget(surname,1,0,1,1)
secondGrid.addWidget(surtx,1,1,1,1)
secondGrid.addWidget(other,2,1,1,1)
secondGrid.addWidget(other,2,2,1,1) </>I would want the whole window to be scrollabe, not only the gBox widget. Please how can I achieve that? I want the scrollarea to be applicable to gbox and secondGbox which make up the gridLayout (main container)
-
Hi,
If you mean the whole "app" class, then you should create the QScrollArea one level above and put the "app" instance in it.
If I may, you should name you class something else, app is just going to be confusing with regard to QApplication for example.