PyQt如何添加滚动区域

时间:2018-07-17 11:16:56

标签: python pyqt pyqt5

我想将网格添加到scrollarea,并希望将其分配给整个窗口。我之前做了Widget,然后分配了网格,然后分配了scrollarea。不幸的是,我无法在整个窗口中完成此操作。在这里我正在使用QStackedWidget,问题是我必须在init_ui的某处添加scrollarea吗?

class App(QMainWindow):
    def __init__(self):
        super().__init__()
        self.report_screen = ReportWindow(self)
        self.company_screen = CompanyWindow(self)
        self.central_widget = QStackedWidget(self)
        self.init_ui()
        self.show()

def init_ui(self):
        main_menu = self.menuBar()

        self.setCentralWidget(self.central_widget)

        self.central_widget.addWidget(self.report_screen)
        self.central_widget.addWidget(self.company_screen)

        self.central_widget.setCurrentWidget(self.report_screen)

class Report(object):
    clicked = pyqtSignal()
    progress = pyqtSignal(str)

    def __init__(self):
        self.grid = QGridLayout(self)

    def detail_report(self):
        for i in range(len(dashboard_obj)):
            self.grid.addWidget(self.label_company(...)
        self.grid.addWidget(self.button, i, 1)

        self.setLayout(self.grid)

    def label_company(self, ...):
    ....


class ReportWindow(QWidget, Report):
    def __init__(self, parent=None):
        super(ReportWindow, self).__init__(parent)
        self.detail_report()

0 个答案:

没有答案