本文整理汇总了Python中PySide.QtGui.QComboBox.setMaxVisibleItems方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setMaxVisibleItems方法的具体用法?Python QComboBox.setMaxVisibleItems怎么用?Python QComboBox.setMaxVisibleItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setMaxVisibleItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ModelWizardPage
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setMaxVisibleItems [as 别名]
class ModelWizardPage(_ExpandableOptionsWizardPage):
class _ModelTypeComboBoxModel(QAbstractListModel):
def __init__(self, model_types=None):
QAbstractListModel.__init__(self)
if model_types is None:
model_types = []
self._model_types = list(model_types)
def rowCount(self, *args, **kwargs):
return len(self._model_types)
def data(self, index, role=Qt.DisplayRole):
if not index.isValid() or \
not (0 <= index.row() < self.rowCount()):
return None
if role == Qt.TextAlignmentRole:
return Qt.AlignCenter
if role != Qt.DisplayRole:
return None
return str(self._model_types[index.row()])
def modelType(self, index):
return self._model_types[index]
class _ModelComboBoxModel(QAbstractListModel):
def __init__(self, models_text=None):
QAbstractListModel.__init__(self)
if models_text is None:
models_text = {}
self._models_text = models_text.copy()
self._models = {}
for model in models_text.keys():
self._models.setdefault(model.type, []).append(model)
self._model_type = None
def rowCount(self, *args, **kwargs):
return len(self._models.get(self._model_type, []))
def data(self, index, role=Qt.DisplayRole):
if not index.isValid() or \
not (0 <= index.row() < self.rowCount()):
return None
if role == Qt.TextAlignmentRole:
return Qt.AlignCenter
if role != Qt.DisplayRole:
return None
model = self._models[self._model_type][index.row()]
return self._models_text[model]
def setModelType(self, model_type):
self._model_type = model_type
self.reset()
def model(self, index):
return self._models[self._model_type][index]
def add(self, model):
if model not in self._models_text:
raise ValueError('No text defined for model: %s' % model)
self._models[model.type].append(model)
self.reset()
def remove(self, model):
self._models[model.type].remove(model)
self.reset()
def __init__(self, options, parent=None):
_ExpandableOptionsWizardPage.__init__(self, options, parent)
self.setTitle('Model')
def _initUI(self):
# Widgets
self._cb_model_type = QComboBox()
self._cb_model_type.setModel(self._ModelTypeComboBoxModel())
self._cb_model = QComboBox()
self._cb_model.setModel(self._ModelComboBoxModel())
self._cb_model.setMaxVisibleItems(10)
btn_model_add = QPushButton()
btn_model_add.setIcon(getIcon("list-add"))
self._tbl_model = ModelTableWidget()
tlb_model = QToolBar()
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
tlb_model.addWidget(spacer)
#.........这里部分代码省略.........