我想QGraphicsItem
使用 sqlalchemy 使 s 持久化。轻松地将 Base 类与 PySide 类结合起来会产生关于元类的错误。metaclsses 主题是 Python 的魔力,我不想在不需要时深入研究它。有没有一种简单的方法来解决这个元类冲突?
class MarketItem(Base, QtGui.QGraphicsEllipseItem, QtGui.QListWidgetItem):
"""
"""
__tablename__ = "marketitem"
Id = Column(Integer(4), primary_key=True)
name = Column(String(40))
x_pos = Column(Integer(4))
y_pos = Column(Integer(4))
def __init__(self, x_pos, y_pos, scene, name, style=QtCore.Qt.SolidLine,
rect=None, matrix=QtGui.QTransform(), cat = None):
super(MarketItem, self).__init__()
self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable|
QtGui.QGraphicsItem.ItemIsMovable|
QtGui.QGraphicsItem.ItemIsFocusable)
self.pos = QtCore.QPoint(x_pos, y_pos)
self.x_pos = x_pos
self.y_pos = y_pos
self.name = name
给出错误:
File "C:\Users\Richard\Documents\manAmpl\aptana\mampl\pm15ConeModel.py", line 47, in <module>
class MarketItem(Base, QtGui.QGraphicsEllipseItem, QtGui.QListWidgetItem):
TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
谢谢,理查德