Hi,

I am writing a custom view for a simple data model and need to have a custom widget change it's background colour when it's associated QStandardItem has a certain attribute. I thought I'd simply subclass QStandardItem, give it the custom attribute, e.g. isSelected, then a method called setSelected() which sets the attribute's value and emits a selectionChanged signal, to which I can connect the associated widget's slot that changes the background colour.
So this is what I have for the item:

class ElemItem(QtGui.QStandardItem):
    selectionChanged = QtCore.Signal(bool)

    def __init__(self, elementData):
        super(ElemItem, self).__init__(elementData)
        self.isSelected = False
        self.filePath = elementData

    def setSelected(self, selected):
        self.isSelected = selected
        selectionChanged.emit(selected)


However, since QStandardItem doesn't inherit QObject it doesn't seem to be able to emit a signal. When I try something like this in the widget:
    self.item.selectionChanged.connect(self.markAsSelected)

I get this error:
AttributeError: 'PySide.QtCore.Signal' object has no attribute 'connect'


Is this the entirely wrong way of achieving what I'm after?
I can achieve what I'm after in other ways but would like to understand this hiccup before moving on, so any input would be welcome.

Cheers,
frank



--
ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing <http://ohufx.com/index.php/vfx-compositing> | *workflow customisation and consulting <http://ohufx.com/index.php/vfx-customising>* *

_______________________________________________
PySide mailing list
PySide@qt-project.org
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to