[PySide] Signal with custom data

275 views
Skip to first unread message

David Angelo

unread,
Sep 6, 2011, 9:12:51 AM9/6/11
to pys...@lists.pyside.org
Hi folks,

I have a question regarding the usage of signals with custom data
objects and not only "str" or "int".
Is it possible to define signals with custom data objects?
E.g.:

class Data(object):
...

class WidgetSource(QtGui.QWidget):

#signal_node_selected = QtCore.Signal(str)
signal_node_selected = QtCore.Signal(<DATA>)

...


class WidgetTarget(QtGui.QWidget):

def __init__(self):
s = WigdgetSource()
s. signal_node_selected.connect(self.slot_node_selected)

def slot_node_selected(self, data):
#process the data object


Thanks in advance and best regards!

Cheers,
David
_______________________________________________
PySide mailing list
PyS...@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Renato Araujo Oliveira Filho

unread,
Sep 6, 2011, 9:19:47 AM9/6/11
to David Angelo, pys...@lists.pyside.org
Hi David,

Yes is possible to define sinal with python objects, you could use:

signal_node_selected = QtCore.Signal(object)

But this signal will be valid only in pyhon side, sice Qt/C++ does not
know how to handle PyObject.

BR

--
Renato Araujo Oliveira Filho
Instituto Nokia de Tecnologia - INdT

David Angelo

unread,
Sep 6, 2011, 9:38:47 AM9/6/11
to Renato Araujo Oliveira Filho, pys...@lists.pyside.org
Hi Renato,

thanks! I only need this signal to be on the python side.

Cheers,
David

Reply all
Reply to author
Forward
0 new messages