本文整理汇总了Python中AnyQt.QtGui.QStandardItemModel.takeRow方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItemModel.takeRow方法的具体用法?Python QStandardItemModel.takeRow怎么用?Python QStandardItemModel.takeRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel.takeRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SelectionSetsWidget
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import takeRow [as 别名]
#.........这里部分代码省略.........
QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
self._addToolButton.setDefaultAction(self._addAction)
self._updateToolButton.setDefaultAction(self._updateAction)
self._removeToolButton.setDefaultAction(self._removeAction)
buttonLayout.addWidget(self._addToolButton)
buttonLayout.addWidget(self._updateToolButton)
buttonLayout.addWidget(self._removeToolButton)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self._addAction.triggered.connect(self.addCurrentSelection)
self._updateAction.triggered.connect(self.updateSelectedSelection)
self._removeAction.triggered.connect(self.removeSelectedSelection)
self._setListView.selectionModel().selectionChanged.connect(
self._onListViewSelectionChanged)
self.selectionModel = None
self._selections = []
def sizeHint(self):
size = QFrame.sizeHint(self)
return QSize(size.width(), 150)
def _onSelectionChanged(self, selected, deselected):
self.setSelectionModified(True)
def _onListViewSelectionChanged(self, selected, deselected):
try:
index = self._setListView.selectedIndexes()[0]
except IndexError:
return
self.commitSelection(self._proxyModel.mapToSource(index).row())
def _onSetNameChange(self, item):
self.selections[item.row()].name = str(item.text())
def _setButtonStates(self, val):
self._updateToolButton.setEnabled(val)
def setSelectionModel(self, selectionModel):
if self.selectionModel:
self.selectionModel.selectionChanged.disconnect(
self._onSelectionChanged)
self.selectionModel = selectionModel
self.selectionModel.selectionChanged.connect(self._onSelectionChanged)
def addCurrentSelection(self):
item = self.addSelection(
SelectionByKey(self.selectionModel.selection(),
name="New selection",
key=(1, 2, 3, 10)))
index = self._proxyModel.mapFromSource(item.index())
self._setListView.setCurrentIndex(index)
self._setListView.edit(index)
self.setSelectionModified(False)
def removeSelectedSelection(self):
i = self._proxyModel.mapToSource(self._setListView.currentIndex()).row()
self._listModel.takeRow(i)
del self.selections[i]
def updateCurentSelection(self):
i = self._proxyModel.mapToSource(self._setListView.selectedIndex()).row()
self.selections[i].setSelection(self.selectionModel.selection())
self.setSelectionModified(False)
def addSelection(self, selection, name=""):
self._selections.append(selection)
item = QStandardItem(selection.name)
item.setFlags(item.flags() ^ Qt.ItemIsDropEnabled)
self._listModel.appendRow(item)
self.setSelectionModified(False)
return item
def updateSelectedSelection(self):
i = self._proxyModel.mapToSource(self._setListView.currentIndex()).row()
self.selections[i].setSelection(self.selectionModel.selection())
self.setSelectionModified(False)
def setSelectionModified(self, val):
self._selectionModified = val
self._setButtonStates(val)
self.selectionModified.emit(bool(val))
def commitSelection(self, index):
selection = self.selections[index]
selection.select(self.selectionModel)
def setSelections(self, selections):
self._listModel.clear()
for selection in selections:
self.addSelection(selection)
def selections(self):
return self._selections
selections = property(selections, setSelections)