[PyQt] converting old signal/slot to new signal/slot

c c coastalchaos at hotmail.co.uk
Wed May 27 16:53:13 BST 2015


Sorry for the formatting here it is again attached as a text file.
 

 
From: coastalchaos at hotmail.co.uk
To: pyqt at riverbankcomputing.com
Subject: converting old signal/slot to new signal/slot
Date: Wed, 27 May 2015 16:43:45 +0100







Hi all,
This is my first post so sorry if I'm missing information. I've researched as much as I can but I can't fathom a way forward. 
I'm having a headache trying to convert old style signal/slots to new style. I'm a newbie and the examples I've read deal with simple use cases and the pyqt 5.4.1 documentation on signals_slots.html hasn't shed light on what I should do. I'm moving an application from 4 to 5 so I can't stay with the old method due to Qt4 support finishing at the end of the year and sip not compiling on mavericks.
 
I've looked at the zetcode tutorials and they use the new style however the Mark Summerfield book which is using the old method. It seems in the old way you could use any object to create a new signal and connect it to a slot  Maybe if I give a scenario it will help explain:- ##############     QT4      example  ########################### #####################################################  So, what I can deduce from that is that the code is creating a signal called "databaseChanged"(PyQt_Object) what will pass an object (any python object) to a slot that has been created and decorated to the on_database_updated_signal method.  If I look at the PyQt5 documentation I have surmised that I need to create a signal using the pyqtSignal() factory and then attach it using the more pythonistic way of doing things. The PyQt5 documentation says I need to connect using     connect(slot, type, noreceiver_check)examples given in the documentation connect the signal to the object doing the connection.I've looked at examples such as http://www.pythoncentral.io/pysidepyqt-tutorial-creating-your-own-signals-and-slots/and I've come up with the below but I feel that something is missing......  ##############     QT5  example      ########################### 
 My question is, is this correct and what happens to the  QtCore.QCoreApplication.instance() I think the emit will also need to change in the above example but I'll take one problem at a time.  Oh, I've also looked at the Qt documentation for QtAssistant and I cant see a change between Qt4 and Qt5 Qobject connect() method so I'm at a loss as to why we have the new signal/slot system in PyQt5 (I am aware that it was introduced in Qt4. I'm sure as I get to grips with pyQt / pyQt5 the reson will become apparent but I'm a long way off of that) Hopefully someone can provide guidance and show me the light. TIA, Rob   
 
 		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150527/4fd541c7/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: convertsignal-slots.txt
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150527/4fd541c7/attachment-0001.txt>


More information about the PyQt mailing list