本文整理汇总了Python中PyQt4.Qt.QListView.selectedIndexes方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.selectedIndexes方法的具体用法?Python QListView.selectedIndexes怎么用?Python QListView.selectedIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QListView
的用法示例。
在下文中一共展示了QListView.selectedIndexes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SelectFormats
# 需要导入模块: from PyQt4.Qt import QListView [as 别名]
# 或者: from PyQt4.Qt.QListView import selectedIndexes [as 别名]
class SelectFormats(QDialog):
def __init__(self, fmt_count, msg, single=False, parent=None, exclude=False):
QDialog.__init__(self, parent)
self._l = QVBoxLayout(self)
self.single_fmt = single
self.setLayout(self._l)
self.setWindowTitle(_("Choose formats"))
self._m = QLabel(msg)
self._m.setWordWrap(True)
self._l.addWidget(self._m)
self.formats = Formats(fmt_count)
self.fview = QListView(self)
self.fview.doubleClicked.connect(self.double_clicked, type=Qt.QueuedConnection)
if exclude:
self.fview.setStyleSheet(
"""
QListView { background-color: #FAE7B5}
"""
)
self._l.addWidget(self.fview)
self.fview.setModel(self.formats)
self.fview.setSelectionMode(self.fview.SingleSelection if single else self.fview.MultiSelection)
self.bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
self._l.addWidget(self.bbox)
self.bbox.accepted.connect(self.accept)
self.bbox.rejected.connect(self.reject)
self.fview.setIconSize(QSize(48, 48))
self.fview.setSpacing(2)
self.resize(350, 500)
self.selected_formats = set([])
def accept(self, *args):
for idx in self.fview.selectedIndexes():
self.selected_formats.add(self.formats.fmt(idx))
QDialog.accept(self, *args)
def double_clicked(self, index):
if self.single_fmt:
self.accept()