本文整理匯總了Python中PySide.QtGui.QListWidget.setViewMode方法的典型用法代碼示例。如果您正苦於以下問題:Python QListWidget.setViewMode方法的具體用法?Python QListWidget.setViewMode怎麽用?Python QListWidget.setViewMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide.QtGui.QListWidget
的用法示例。
在下文中一共展示了QListWidget.setViewMode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: QtReducePreferencePane
# 需要導入模塊: from PySide.QtGui import QListWidget [as 別名]
# 或者: from PySide.QtGui.QListWidget import setViewMode [as 別名]
class QtReducePreferencePane(QDialog):
# QtReducePreferencePane are the dialog windows for setting preferences.
# Instances are created via menu or keyboard shortcut in QtReduceMainWindow.
def __init__(self, parent=None):
super(QtReducePreferencePane, self).__init__(parent)
self.__createContents()
self.toolBar = QtReducePreferencesToolBar(self)
self.worksheet = QtReducePreferencesWorksheet(self)
self.computation = QtReducePreferencesComputation(self)
self.pagesWidget = QStackedWidget()
self.pagesWidget.addWidget(self.toolBar)
self.pagesWidget.addWidget(self.worksheet)
self.pagesWidget.addWidget(self.computation)
self.pagesWidget.setCurrentIndex(
self.contentsWidget.row(self.contentsWidget.currentItem()))
closeButton = QPushButton(self.tr("Close"))
closeButton.clicked.connect(self.close)
horizontalLayout = QHBoxLayout()
horizontalLayout.addWidget(self.contentsWidget)
horizontalLayout.addWidget(self.pagesWidget)
buttonsLayout = QHBoxLayout()
buttonsLayout.addStretch(1)
buttonsLayout.addWidget(closeButton)
mainLayout = QVBoxLayout()
mainLayout.addLayout(horizontalLayout)
mainLayout.addLayout(buttonsLayout)
self.setLayout(mainLayout)
self.setWindowTitle(self.tr("QReduce Preferences"))
def changePage(self,current,previous):
if not current:
current = previous
QSettings().setValue("preferences/currentitem",current.text())
self.pagesWidget.setCurrentIndex(self.contentsWidget.row(current))
def __createContents(self):
self.contentsWidget = QListWidget()
self.contentsWidget.setViewMode(QListView.ListMode)
self.contentsWidget.setMovement(QListView.Static)
toolBar = QListWidgetItem(self.contentsWidget)
toolBar.setText(self.tr("Toolbar"))
toolBar.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
worksheet = QListWidgetItem(self.contentsWidget)
worksheet.setText(self.tr("Worksheet"))
worksheet.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
computation = QListWidgetItem(self.contentsWidget)
computation.setText(self.tr("Computation"))
computation.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
currentItem = QSettings().value("preferences/currentitem",
self.tr(QtReduceDefaults.CURRENTITEM))
if currentItem == self.tr("Toolbar"):
self.contentsWidget.setCurrentItem(toolBar)
elif currentItem == self.tr("Worksheet"):
self.contentsWidget.setCurrentItem(worksheet)
elif currentItem == self.tr("Computation"):
self.contentsWidget.setCurrentItem(computation)
self.contentsWidget.currentItemChanged.connect(self.changePage)