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

c c coastalchaos at hotmail.co.uk
Thu May 28 08:07:12 BST 2015


Oh, I'm using PyQt 5.4.1, sip 4.16.7 and Qt binaries 5.4.1



On 28 May 2015, at 07:51, "c c" <coastalchaos at hotmail.co.uk> wrote:

> Baz,
> 
> Thanks. I have read the articles that you mentioned and mentioned them in my post, I should have provided a full link.
> 
> I'll search through the examples and see where they will lead me. I have the source as I compiled pyqt5 on my mac with the latest sip.
> 
> I think the thing that was/is confusing me is that the old style used the qcoreapplication.instance() as the object in the connect() method where the new style simply links the slot as the argument of the signals connect method. 
> 
> Yes I agree the new style is cleaner, I'm just trying to understand the code as it was so I can refactor it to the new style to move forward with pyqt5/qt5 now and not have to worry in the future.
> 
> Thanks
> 
> Sent from my iPad
> 
> On 27 May 2015, at 19:08, "Baz Walter" <bazwal at ftml.net> wrote:
> 
>> On 27/05/15 16:43, c c wrote:
>>> 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.
>> 
>> As you say, the new-style signal and slot syntax was introduced in PyQt4. I think that would have been with version 4.5, though, and so the old-style syntax had to be maintained alongside it for the purposes of backwards compatibility. The new-style syntax has been around for almost six years, now - so it's hardly "new" any more.
>> 
>> Why introduce the new-style syntax? Well, the old-style syntax is verbose, difficult to get right (especially if you don't know C++), and does not raise errors if you get it wrong. The new-style syntax is simply much more pythonic, and, now that PyQt5 can break compatibility with PyQt4, there is no need to maintain support for the old-style syntax - and so it has gone. In most other respects, though, PyQt5 is still very similar to PyQt4, and so porting is not usually a significant burden.
>> 
>> For more details, I suggest you go to the PyQt5 docs and read through the "Support for Signals and Slots" section:
>> 
>>   http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html
>> 
>> and the "Differences Between PyQt4 and PyQt5" section:
>> 
>>   http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html
>> 
>> If you want up-to-date example code, download the PyQt source from here:
>> 
>>   http://www.riverbankcomputing.com/software/pyqt/download5
>> 
>> and consult the README file in the examples directory.
>> 
>> -- 
>> Regards
>> Baz Walter
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list