本文整理汇总了Python中PyQt5.QtCore.QPointF.isNull方法的典型用法代码示例。如果您正苦于以下问题:Python QPointF.isNull方法的具体用法?Python QPointF.isNull怎么用?Python QPointF.isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QPointF
的用法示例。
在下文中一共展示了QPointF.isNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressed
# 需要导入模块: from PyQt5.QtCore import QPointF [as 别名]
# 或者: from PyQt5.QtCore.QPointF import isNull [as 别名]
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:
moveBy = QPointF(1, 0)
else:
super().keyPressed(event)
return
items = self.mapScene().selectedObjectItems()
modifiers = event.modifiers()
if (moveBy.isNull() or items.isEmpty() or (modifiers & Qt.ControlModifier)):
event.ignore()
return
moveFast = modifiers & Qt.ShiftModifier
snapToFineGrid = preferences.Preferences.instance().snapToFineGrid()
if (moveFast):
# TODO: This only makes sense for orthogonal maps
moveBy.setX(moveBy.x() * self.mapDocument().map().tileWidth())
moveBy.setX(moveBy.y() * self.mapDocument().map().tileHeight())
if (snapToFineGrid):
moveBy /= preferences.Preferences.instance().gridFine()
undoStack = self.mapDocument().undoStack()
undoStack.beginMacro(self.tr("Move %n Object(s)", "", items.size()))
i = 0
for objectItem in items:
object = objectItem.mapObject()
oldPos = object.position()
newPos = oldPos + moveBy
undoStack.push(MoveMapObject(self.mapDocument(), object, newPos, oldPos))
i += 1
undoStack.endMacro()