Python pyqt5 vertical scroll bar is always maximum

Viewed 18

I have created a scroll area using designer.I want to show number of group box with 3 labels in it. All is running good except for scroll bar which is always full. The following output will let you understand it.

As you can see there is half group box. It should be shown when scrolled but scroll bar is not working This is my code I have made quite changes in the original file.This is code for scroll area

        self.scroll = QScrollArea()
        self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scroll.setWidgetResizable(True)
        self.scroll.setGeometry(QtCore.QRect(0, 0, 529, 249))
        self.scroll.setObjectName("scrollAreaWidgetContents")

This the code of widgets inside the Scroll area i.e(group box with 3 labels)

        for i in dat:
            lsst = i.split("|")
            g_y = 20
            l_y = 30
            l2n3_y = 60
            self.groupBox = QtWidgets.QGroupBox(self.scroll)
            self.groupBox.setGeometry(QtCore.QRect(50, g_y + 90 * mul, 431, 85))
            self.groupBox.setTitle("")
            self.groupBox.setObjectName("groupBox")
            self.label = QLabel(self.scroll)
            self.label.setObjectName(u"label")
            self.label.setGeometry(QRect(80, l_y + 90 * mul, 371, 21))
            font = QFont()
            font.setBold(True)
            font.setWeight(75)
            self.label.setFont(font)
            self.label.setIndent(-1)
            self.label_2 = QLabel(self.scroll)
            self.label_2.setObjectName(u"label_2")
            self.label_2.setGeometry(QRect(80, l2n3_y + 90 * mul, 371, 16))
            font1 = QFont()
            font1.setFamily(u"Arial")
            font1.setPointSize(8)
            font1.setBold(False)
            font1.setWeight(50)
            self.label_2.setFont(font1)
            self.label_2.setIndent(-1)
            self.label_3 = QLabel(self.scroll)
            self.label_3.setObjectName(u"label_3")
            self.label_3.setGeometry(QRect(390, l2n3_y + 90 * mul, 91, 16))
            self.label_3.setFont(font1)
            self.label_3.setIndent(-1)
            mul = mul + 1
            self.label.setText(lsst[0])
            self.label_2.setText(lsst[1])
            self.label_3.setText(lsst[2])
0 Answers
Related