我正在构建一个pyqtqgraphicsview项目,其中一些QGraphicItems可以在不同的qgraphicsitems组之间移动。为此,我使用“new”父项组的addItemToGroup()方法。在
这很好,但前提是我没有在自定义子项类中定义itemChange()方法。一旦我定义了那个方法(即使我只是将函数调用传递给超级类),不管我做什么尝试,childItems都不会被添加到ItemGroups中。在
class MyChildItem(QtGui.QGraphicsItemGroup):
def itemChange(self, change, value):
# TODO: Do something for certain cases of ItemPositionChange
return QtGui.QGraphicsItemGroup.itemChange(self, change, value)
#return super().itemChange(change, value) # Tried this variation too
#return value # Tried this too, should work according to QT doc
我是不是太蠢了,不能在Python中正确调用超类方法,还是问题出在QT/PyQT魔法中?在
我在pyqt4.8和qt5中使用python3.3。在
我也有同样的问题。也许这个:http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg27457.html回答了你的一些问题? 看来我们在PyQt4可能会走运。在
更新: 实际上,只是找到了一个解决办法:
从这里拍摄:http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg26190.html
也许不是最优雅和通用的解决方案,但在这里,它是有效的,我可以添加QGraphicItems到QGraphicItemGroups。在
相关问题 更多 >
编程相关推荐