本文整理汇总了Python中pyqtcore.QVector.remove方法的典型用法代码示例。如果您正苦于以下问题:Python QVector.remove方法的具体用法?Python QVector.remove怎么用?Python QVector.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QVector
的用法示例。
在下文中一共展示了QVector.remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MapScene
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import remove [as 别名]
class MapScene(QGraphicsScene):
selectedObjectItemsChanged = pyqtSignal()
##
# Constructor.
##
def __init__(self, parent):
super().__init__(parent)
self.mMapDocument = None
self.mSelectedTool = None
self.mActiveTool = None
self.mObjectSelectionItem = None
self.mUnderMouse = False
self.mCurrentModifiers = Qt.NoModifier,
self.mDarkRectangle = QGraphicsRectItem()
self.mDefaultBackgroundColor = Qt.darkGray
self.mLayerItems = QVector()
self.mObjectItems = QMap()
self.mObjectLineWidth = 0.0
self.mSelectedObjectItems = QSet()
self.mLastMousePos = QPointF()
self.mShowTileObjectOutlines = False
self.mHighlightCurrentLayer = False
self.mGridVisible = False
self.setBackgroundBrush(self.mDefaultBackgroundColor)
tilesetManager = TilesetManager.instance()
tilesetManager.tilesetChanged.connect(self.tilesetChanged)
tilesetManager.repaintTileset.connect(self.tilesetChanged)
prefs = preferences.Preferences.instance()
prefs.showGridChanged.connect(self.setGridVisible)
prefs.showTileObjectOutlinesChanged.connect(self.setShowTileObjectOutlines)
prefs.objectTypesChanged.connect(self.syncAllObjectItems)
prefs.highlightCurrentLayerChanged.connect(self.setHighlightCurrentLayer)
prefs.gridColorChanged.connect(self.update)
prefs.objectLineWidthChanged.connect(self.setObjectLineWidth)
self.mDarkRectangle.setPen(QPen(Qt.NoPen))
self.mDarkRectangle.setBrush(Qt.black)
self.mDarkRectangle.setOpacity(darkeningFactor)
self.addItem(self.mDarkRectangle)
self.mGridVisible = prefs.showGrid()
self.mObjectLineWidth = prefs.objectLineWidth()
self.mShowTileObjectOutlines = prefs.showTileObjectOutlines()
self.mHighlightCurrentLayer = prefs.highlightCurrentLayer()
# Install an event filter so that we can get key events on behalf of the
# active tool without having to have the current focus.
QCoreApplication.instance().installEventFilter(self)
##
# Destructor.
##
def __del__(self):
if QCoreApplication.instance():
QCoreApplication.instance().removeEventFilter(self)
##
# Returns the map document this scene is displaying.
##
def mapDocument(self):
return self.mMapDocument
##
# Sets the map this scene displays.
##
def setMapDocument(self, mapDocument):
if (self.mMapDocument):
self.mMapDocument.disconnect()
if (not self.mSelectedObjectItems.isEmpty()):
self.mSelectedObjectItems.clear()
self.selectedObjectItemsChanged.emit()
self.mMapDocument = mapDocument
if (self.mMapDocument):
renderer = self.mMapDocument.renderer()
renderer.setObjectLineWidth(self.mObjectLineWidth)
renderer.setFlag(RenderFlag.ShowTileObjectOutlines, self.mShowTileObjectOutlines)
self.mMapDocument.mapChanged.connect(self.mapChanged)
self.mMapDocument.regionChanged.connect(self.repaintRegion)
self.mMapDocument.tileLayerDrawMarginsChanged.connect(self.tileLayerDrawMarginsChanged)
self.mMapDocument.layerAdded.connect(self.layerAdded)
self.mMapDocument.layerRemoved.connect(self.layerRemoved)
self.mMapDocument.layerChanged.connect(self.layerChanged)
self.mMapDocument.objectGroupChanged.connect(self.objectGroupChanged)
self.mMapDocument.imageLayerChanged.connect(self.imageLayerChanged)
self.mMapDocument.currentLayerIndexChanged.connect(self.currentLayerIndexChanged)
self.mMapDocument.tilesetTileOffsetChanged.connect(self.tilesetTileOffsetChanged)
self.mMapDocument.objectsInserted.connect(self.objectsInserted)
self.mMapDocument.objectsRemoved.connect(self.objectsRemoved)
self.mMapDocument.objectsChanged.connect(self.objectsChanged)
self.mMapDocument.objectsIndexChanged.connect(self.objectsIndexChanged)
self.mMapDocument.selectedObjectsChanged.connect(self.updateSelectedObjectItems)
self.refreshScene()
##
# Returns whether the tile grid is visible.
##
def isGridVisible(self):
return self.mGridVisible
#.........这里部分代码省略.........
示例2: ObjectTypesModel
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import remove [as 别名]
class ObjectTypesModel(QAbstractTableModel):
ColorRole = Qt.UserRole
def __init__(self, parent):
super().__init__(parent)
self.mObjectTypes = QVector()
def setObjectTypes(self, objectTypes):
self.beginResetModel()
self.mObjectTypes = objectTypes
self.endResetModel()
def objectTypes(self):
return self.mObjectTypes
def rowCount(self, parent):
if parent.isValid():
_x = 0
else:
_x = self.mObjectTypes.size()
return _x
def columnCount(self, parent):
if parent.isValid():
_x = 0
else:
_x = 2
return _x
def headerData(self, section, orientation, role):
if (orientation == Qt.Horizontal):
if (role == Qt.DisplayRole):
x = section
if x==0:
return self.tr("Type")
elif x==1:
return self.tr("Color")
elif (role == Qt.TextAlignmentRole):
return Qt.AlignLeft
return QVariant()
def data(self, index, role):
# QComboBox requests data for an invalid index when the model is empty
if (not index.isValid()):
return QVariant()
objectType = self.mObjectTypes.at(index.row())
if (role == Qt.DisplayRole or role == Qt.EditRole):
if (index.column() == 0):
return objectType.name
if (role == ObjectTypesModel.ColorRole and index.column() == 1):
return objectType.color
return QVariant()
def setData(self, index, value, role):
if (role == Qt.EditRole and index.column() == 0):
self.mObjectTypes[index.row()].name = value.strip()
self.dataChanged.emit(index, index)
return True
return False
def flags(self, index):
f = super().flags(index)
if (index.column() == 0):
f |= Qt.ItemIsEditable
return f
def setObjectTypeColor(self, objectIndex, color):
self.mObjectTypes[objectIndex].color = color
mi = self.index(objectIndex, 1)
self.dataChanged.emit(mi, mi)
def removeObjectTypes(self, indexes):
rows = QVector()
for index in indexes:
rows.append(index.row())
rows = sorted(rows)
for i in range(len(rows) - 1, -1, -1):
row = rows[i]
self.beginRemoveRows(QModelIndex(), row, row)
self.mObjectTypes.remove(row)
self.endRemoveRows()
def appendNewObjectType(self):
self.beginInsertRows(QModelIndex(), self.mObjectTypes.size(), self.mObjectTypes.size())
self.mObjectTypes.append(ObjectType())
self.endInsertRows()
示例3: ObjectSelectionTool
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import remove [as 别名]
class ObjectSelectionTool(AbstractObjectTool):
def __init__(self, parent = None):
super().__init__(self.tr("Select Objects"),
QIcon(":images/22x22/tool-select-objects.png"),
QKeySequence(self.tr("S")),
parent)
self.mSelectionRectangle = SelectionRectangle()
self.mOriginIndicator = OriginIndicator()
self.mMousePressed = False
self.mHoveredObjectItem = None
self.mClickedObjectItem = None
self.mClickedRotateHandle = None
self.mClickedResizeHandle = None
self.mResizingLimitHorizontal = False
self.mResizingLimitVertical = False
self.mMode = Mode.Resize
self.mAction = Action.NoAction
self.mRotateHandles = [0, 0, 0, 0]
self.mResizeHandles = [0, 0, 0, 0, 0, 0, 0, 0]
self.mAlignPosition = QPointF()
self.mMovingObjects = QVector()
self.mScreenStart = QPoint()
self.mStart = QPointF()
self.mModifiers = 0
self.mOrigin = QPointF()
for i in range(AnchorPosition.CornerAnchorCount):
self.mRotateHandles[i] = RotateHandle(i)
for i in range(AnchorPosition.AnchorCount):
self.mResizeHandles[i] = ResizeHandle(i)
def __del__(self):
if self.mSelectionRectangle.scene():
self.mSelectionRectangle.scene().removeItem(self.mSelectionRectangle)
if self.mOriginIndicator.scene():
self.mOriginIndicator.scene().removeItem(self.mOriginIndicator)
for i in range(AnchorPosition.CornerAnchorCount):
handle = self.mRotateHandles[i]
scene = handle.scene()
if scene:
scene.removeItem(handle)
self.mRotateHandles.clear()
for i in range(AnchorPosition.AnchorCount):
handle = self.mResizeHandles[i]
scene = handle.scene()
if scene:
scene.removeItem(handle)
self.mResizeHandles.clear()
def tr(self, sourceText, disambiguation = '', n = -1):
return QCoreApplication.translate('ObjectSelectionTool', sourceText, disambiguation, n)
def activate(self, scene):
super().activate(scene)
self.updateHandles()
self.mapDocument().objectsChanged.connect(self.updateHandles)
self.mapDocument().mapChanged.connect(self.updateHandles)
scene.selectedObjectItemsChanged.connect(self.updateHandles)
self.mapDocument().objectsRemoved.connect(self.objectsRemoved)
if self.mOriginIndicator.scene() != scene:
scene.addItem(self.mOriginIndicator)
for i in range(AnchorPosition.CornerAnchorCount):
handle = self.mRotateHandles[i]
if handle.scene() != scene:
scene.addItem(handle)
for i in range(AnchorPosition.AnchorCount):
handle = self.mResizeHandles[i]
if handle.scene() != scene:
scene.addItem(handle)
def deactivate(self, scene):
if self.mOriginIndicator.scene() == scene:
scene.removeItem(self.mOriginIndicator)
for i in range(AnchorPosition.CornerAnchorCount):
handle = self.mRotateHandles[i]
if handle.scene() == scene:
scene.removeItem(handle)
for i in range(AnchorPosition.AnchorCount):
handle = self.mResizeHandles[i]
if handle.scene() == scene:
scene.removeItem(handle)
self.mapDocument().objectsChanged.disconnect(self.updateHandles)
self.mapDocument().mapChanged.disconnect(self.updateHandles)
scene.selectedObjectItemsChanged.disconnect(self.updateHandles)
super().deactivate(scene)
def keyPressed(self, event):
if (self.mAction != Action.NoAction):
event.ignore()
return
moveBy = QPointF()
x = event.key()
if x==Qt.Key_Up:
moveBy = QPointF(0, -1)
elif x==Qt.Key_Down:
moveBy = QPointF(0, 1)
elif x==Qt.Key_Left:
moveBy = QPointF(-1, 0)
elif x==Qt.Key_Right:
#.........这里部分代码省略.........