Python Forum
[PyQt] How do I get a QScrollArea to scroll?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] How do I get a QScrollArea to scroll?
#1
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)

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)
Reply


Messages In This Thread
How do I get a QScrollArea to scroll? - by LavaCreeperKing - Oct-22-2021, 06:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QScrollArea does not work HeinKurz 3 2,886 Jan-24-2023, 09:45 PM
Last Post: HeinKurz
  [PyQt] QTableView: scroll to top cell of the screen random_nick 2 4,895 Oct-08-2022, 12:29 AM
Last Post: random_nick
  Treeview scroll selected node to top rfresh737 1 3,677 Apr-14-2021, 03:27 AM
Last Post: deanhystad
  [Tkinter] canvas widget scroll issue chrisdb 2 5,480 Apr-07-2021, 05:48 AM
Last Post: chrisdb
  [Tkinter] Help with scroll bars kraco 1 2,922 Sep-27-2020, 11:20 PM
Last Post: Larz60+
  [Tkinter] How to place scroll bar correctly scratchmyhead 1 4,772 May-18-2020, 04:17 PM
Last Post: scratchmyhead
  Scroll frame with MouseWheel Nemesis 1 5,409 Mar-25-2020, 09:29 PM
Last Post: Nemesis
  [Kivy] Why I have to click twice to scroll? Hummingbird 0 2,794 Jan-06-2020, 09:08 PM
Last Post: Hummingbird
  Require scroll bars horizontal and vertical throughout the window tejgandhi 2 3,407 Jun-28-2019, 03:13 AM
Last Post: tejgandhi
  [Tkinter] Scroll Bars going backwards goofygoo 2 3,501 Jun-07-2019, 05:07 PM
Last Post: goofygoo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020