Oct-22-2021, 06:09 PM
A lot of people seem to have this problem. How do I get a QScrollArea to scroll. I have this code below that creates widgets and places them in lines in a QScrollArea to display information. I need to set 4 widgest per line and space them out properly to display all the needed information. The problem in I cant get the ScrollArea to scroll.
(Using PyQt5)
If anyone is wondering I am working on a tool to replace dnfdrogora(A Linux graphical package manager tool)
(Using PyQt5)
self.pkg_display = QtWidgets.QScrollArea(self) self.pkg_display.setGeometry(10, 40, 801, 401) self.pkg_display.setStyleSheet("background-color: White") self.pkg_display.setVerticalScrollBarPolicy(2) self.pkg_display.setWidgetResizable(True) self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(0, 0, 801, 800) self.pkg_display.setWidget(self.scrollAreaWidgetContents)
def update_list(): pos = 0 x1 = 10 y1 = 2 x2 = 393 y2 = 5 x3 = 700 x4 = 756 for i in filtered_name: cb = QtWidgets.QCheckBox(ui.scrollAreaWidgetContents) cb.setGeometry(x1,y1,361,23) cb.setText(i) vtext = QtWidgets.QLabel(ui.scrollAreaWidgetContents) vtext.setGeometry(x2,y2,291,17) vtext.setText(filtered_version[pos]) stext = QtWidgets.QLabel(ui.scrollAreaWidgetContents) stext.setGeometry(x3,y2,51,17) stext.setText(filtered_size[pos]) ib = QtWidgets.QPushButton(ui.scrollAreaWidgetContents) ib.setGeometry(x4,y1,21,21) ib.setText("i") y1 += 23 y2 += 23 pos += 1 ui.pkg_display.update()The code creates the widjets and places them in the ScrollArea(pkg_dsiplay), but it will not scroll.
If anyone is wondering I am working on a tool to replace dnfdrogora(A Linux graphical package manager tool)