本文整理汇总了Python中pyqtcore.QList.first方法的典型用法代码示例。如果您正苦于以下问题:Python QList.first方法的具体用法?Python QList.first怎么用?Python QList.first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QList
的用法示例。
在下文中一共展示了QList.first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: selectionChanged
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import first [as 别名]
def selectionChanged(self, selected, deselected):
super().selectionChanged(selected, deselected)
if (not self.mMapDocument or self.mSynching):
return
selectedRows = self.selectionModel().selectedRows()
currentLayerIndex = -1
selectedObjects = QList()
for index in selectedRows:
og = self.model().toLayer(index)
if og:
i = self.mMapDocument.map().layers().indexOf(og)
if (currentLayerIndex == -1):
currentLayerIndex = i
elif (currentLayerIndex != i):
currentLayerIndex = -2
o = self.model().toMapObject(index)
if o:
selectedObjects.append(o)
# Switch the current object layer if only one object layer (and/or its objects)
# are included in the current selection.
if (currentLayerIndex >= 0 and currentLayerIndex != self.mMapDocument.currentLayerIndex()):
self.mMapDocument.setCurrentLayerIndex(currentLayerIndex)
if (selectedObjects != self.mMapDocument.selectedObjects()):
self.mSynching = True
if (selectedObjects.count() == 1):
o = selectedObjects.first()
center = o.bounds().center()
DocumentManager.instance().centerViewOn(center)
self.mMapDocument.setSelectedObjects(selectedObjects)
self.mSynching = False