<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>David,</div><div><br></div><div>Thanks.</div><div><br></div><div>The tutorial had a PyQt option. Click PyQt at the top of the code examples.</div><div><br></div><div>I do get the new style now thanks to your and other replies to the post.</div><div><br></div><div>I'm now wondering why adore application.instance() was the object as the parameter of the old style in my given example. </div><div><br></div><div>Was it trying to make sure the signal was only connected to a slot in that instance of qcoreplication? As its not wrapped up I'm assuming there will be only one instance of it?</div><div><br></div><div>I've been going through the code and am running it, fixing a signal/slot error then running it again. Just working my way through, but I don't want to break what I already have. </div><div><br></div><div>I'm trying to upgrade the code I have before moving forward with the rest of the project. </div><div><br></div><div>Rob </div><div><br></div><div><br><br>Sent from my iPad</div><div><br>On 27 May 2015, at 20:32, "David Cortesi" <<a href="mailto:davecortesi@gmail.com">davecortesi@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>I'll try to clarify the new slot/signal style a bit, hopefully somebody else will fill in more.<br><br></div>To start, just forget the old style entirely. A signal is a property of an object. It happens to have a method connect(). Thus<br><br></div> input_line = QLineEdit()<br></div> input_line.editingFinished.connect( self.accept_input_line )<br><br></div>The argument to connect is an executable, typically self.some_method but often just a slot (i.e. method) on some other widget, as when you have an Edit menu with an Undo action, and you do<br><br></div> undo_action = my_edit_menu.addAction( QAction('Undo') )<br></div> undo_action.triggered.connect( my_plain_text_editor.undo )<br><br></div>(The "slot' executable can even be a lambda! Which is sometimes quite handy.)<br><br>You are trying to create a signal of your own. I don't think much of the python central tutorial you linked, it seems oriented to PySide and doesn't seem to match up with the PyQt5 doc, here:<br><br> <a href="http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html">http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html</a><br><br></div>Follow the syntax under "Defining new signals with pyQtSignal". You are defining a class property, i.e. declared at the top level of a class definition, and what is not made explicit in that writeup, is that the class must derive from QObject (not python's object). Once you have defined the signal, e.g.<br><br></div> class myWidget( QWidget ):<br></div> databaseChanged = pyQtSignal()<br><br></div>it is a property of the class ergo of every object of the class. In the __init__ probably you would do something like,<br><br></div> self.databaseChanged.connect( self.react_to_db )<br><br></div>Or possibly in some OTHER object's __init__ it creates a myWidget and connects it:<br><br></div> new_widgy = myWidget(blah blah)<br></div> new_widgy.databaseChanged.connect( self.catch_new_widgy )<br><br></div><div>When it is time to emit the signal, you just invoke its emit method,<br><br></div><div> if database_has_changed :<br></div><div> self.databaseChanged.emit()<br><br></div>It looks as if you are trying to have your signal not just exist but pass a parameter? The syntax for that in pyQtSignal is a bit obscure and I'm not comfortable with it so maybe somebody else can write about that.<br><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a></span><br><span><a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></span></div></blockquote></body></html>