Why does this multiple class inheritance not work? It appears I'm doing something incorrect. I'm trying to create a baseclass that has a property of UID and when that property is change it calls self.update forcing the graphics item's paint event to be triggered. The reason for the baseclass is so i can implement this property across all other custom GraphicItems that I'll be eventually creating. Not all of them will be TextItems.
import os, sys, uuid
from Qt import QtWidgets, QtGui, QtCore
class AbstractNodeItem(QtWidgets.QGraphicsItem):
def __init__(self, parent=None):
super(AbstractNodeItem, self).__init__(parent)
self.setFlags(self.ItemIsSelectable | self.ItemIsMovable)
self.setZValue(0)
# private
self.m_uid = uuid.uuid4().hex
# Getters/Setters
def getUid(self):
return self.m_uid
def setUid(self, value=''):
self.m_uid = value
class StickyNoteNodeItem(AbstractNodeItem, QtWidgets.QGraphicsTextItem):
def __init__(self, parent=None):
super(StickyNoteNodeItem, self).__init__(parent)
def printProperties(item):
print '>>>>>', item.getUid()
a = AbstractNodeItem()
b = StickyNoteNodeItem()
printProperties(a)
printProperties(b)