我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PySide.QtGui.QScrollArea()。
def createTaskWidgets(self): '''Create one task widget for every task found in current task store''' ## START OF NAUGHTY CODE # DELETE TASK CONTAINER AND SCROLL AREA SO WE CAN RE-CREATE THEM # FOR SOME REASON RE-USING THE EXISTING ONES DOES NOT SHOW THE TASK WIDGETS self.taskContainer.deleteLater() self.scrollArea.deleteLater() self.taskContainer = QtGui.QWidget() self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidget(self.taskContainer) self.layout().addWidget(self.scrollArea) ## END OF NAUGHTY CODE self.taskWidgets = [TaskWidget(t, self.taskContainer) for t in self.taskStore.tasks] self.update()
def LayoutDesign(self): self.widget = QtGui.QWidget() self.layout = QtGui.QGridLayout(self.widget) self.layout.setSpacing(1) self.layout.setHorizontalSpacing(0) self.layout.setVerticalSpacing(0) self.scroll = QtGui.QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setWidget(self.widget) self.LayoutChangesOnSliceChange(self.Electrode.slices) self.layout.addWidget(self.CustomWebView, 1, 0,1,25, QtCore.Qt.AlignLeft) self.layout.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0) self.grid1 = QtGui.QGridLayout() self.grid1.addWidget(self.scroll,3,0) self.setLayout(self.grid1)
def setupUI(self): mainLayout = QtGui.QVBoxLayout() self.setLayout(mainLayout) self.buttonLayout = QtGui.QHBoxLayout() self.msg = QtGui.QLabel() self.addTaskButton = QtGui.QPushButton('Add Task') self.addTaskButton.setToolTip('Add a new task to the list') self.sortButton = QtGui.QPushButton('Reverse Sorting') self.sortButton.setCheckable(True) self.sortButton.setToolTip('Push to sort so highest priorities are at the top,\notherwise lowest will be at the top.') self.helpButton = QtGui.QPushButton('?') self.helpButton.setMaximumWidth(30) self.helpButton.setFlat(True) self.helpButton.setToolTip(self.__helpText()) self.hideButton = QtGui.QPushButton('Hide Finished Tasks') self.hideButton.setCheckable(True) self.hideButton.setToolTip('Hide finished tasks to keep the list tidy') self.clipboardButton = QtGui.QPushButton('Copy To Clipboard') self.clipboardButton.setToolTip('Push to copy current task info to cliboard for pasting into emails or other text documents.\nHandy to keep those coordinators happy.') self.buttonLayout.addWidget(self.addTaskButton) self.buttonLayout.addWidget(self.sortButton) self.buttonLayout.addWidget(self.hideButton) self.buttonLayout.addWidget(self.clipboardButton) self.buttonLayout.addSpacing(20) self.buttonLayout.addWidget(self.helpButton) self.layout().addWidget(self.msg) self.layout().addLayout(self.buttonLayout) self.taskContainer = QtGui.QWidget() self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidget(self.taskContainer) self.layout().addWidget(self.scrollArea) self.createTaskWidgets() self.update()