<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mar 29 ott 2019 alle ore 15:21 Dennis Jensen <<a href="mailto:djensen@pgcontrols.com">djensen@pgcontrols.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Actually I do not think the pyqtSlot can take that data type from what I <br>
understand is they only deal in primitives (int, str, object)<br></blockquote><div><br></div><div>No, any python type object (even custom ones) or string representations of Qt classes can be used:</div><div><a href="https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html#the-pyqtslot-decorator">https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html#the-pyqtslot-decorator</a><br></div><div><br></div><div>So, all the following decorators are valid and correctly recognized (or raise errors if the signal is not recognized as compatible):</div><div><br></div><div><div><font face="monospace">class SomeCustomObject(object):</font></div><div><font face="monospace"> def __init__(self):</font></div><div><font face="monospace"> self.color = QtGui.QColor(QtCore.Qt.red)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">class MySender(QtCore.QObject):</font></div><div><font face="monospace"> mySignal = QtCore.pyqtSignal([SomeCustomObject], [SomeCustomObject, QtGui.QColor], ['QColor'])</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">class MyReceiver(QtCore.QObject):</font></div><div><font face="monospace"> @QtCore.pyqtSlot(SomeCustomObject)</font></div><div><font face="monospace"> def slotTest(self, obj):</font></div><div><font face="monospace"> print(obj.color.getRgb())</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> @QtCore.pyqtSlot(SomeCustomObject, QtGui.QColor)</font></div><div><font face="monospace"> def slotTest(self, obj, color):</font></div><div><font face="monospace"> print(obj.color.getRgb(), color.getRgb())</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> @QtCore.pyqtSlot('QColor')</font></div><div><font face="monospace"> def slotTest(self, color):</font></div><div><font face="monospace"> print(color.getRgb())</font></div></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div></div></div></div></div></div>