[PyQt] why use the non-gui Qt classes in Python

Kyle Altendorf sda at fstab.net
Fri Aug 17 22:54:37 BST 2018

Twisted does async serial.  I'll reiterate the loss of exceptions when you use Qt features over their Python counterparts.  For sequencing, inlineCallbacks/async-await are really nice as well (maybe someday I'll make something so you can yield for a signal too...) so for more than just a basic request/response the Qt stuff loses some benefits as you start chaining signals and slots.  But yes, for interactive subprocessing, QProcess is great.  Much better than the stuff people roll themselves with threads and subprocess.  I think better than Twisted as well, but I forget the details.

In general, I personally take the non-Qt option unless Qt offers a specific benefit. I'm much more likely to want to leverage my existing code or library knowledge without Qt than without Python.


On August 17, 2018 4:00:22 PM EDT, Maurizio Berti <maurizio.berti at gmail.com> wrote:
>Also, some functionalities are much more complete in Qt, and there's
>consistency using a single (almost always) coherent framework than
>different (external) modules, which differ by syntax, naming
>argument order and error handling.
>Finally, a more comprehensive cross-platform support (for example
>path support, which always uses "/" and doesn't need complex handling
>os.path.join and os.path.sep).
>Il giorno ven 17 ago 2018 alle ore 18:05 Florian Bruhin
><me at the-compiler.org>
>ha scritto:
>> On Fri, Aug 17, 2018 at 11:59:17AM -0400, Christopher Probst wrote:
>> > Beyond signals and slots, is there any advantage in using the
>non-GUI Qt
>> > classes in a PyQt application. Why would I use QSQLDatabase, the
>> > module if Python offers it already?
>> There are sometimes reasons - some examples:
>> - In general, things being async, i.e. not blocking your GUI
>>   networking, QSerial vs. PySerial, etc.)
>> - QSqlDatabase because you want to show it in a QTableView
>> - Better integration with Qt in general (e.g. QThread)
>> - Some functionality which is just nicer in Qt (QUrl vs. a
>>   tuple)
>> - Some functionality which doesn't exist in Python
>> Often, the main drawback is the more complex error handling, as you
>> manual error checks instead of exceptions.
>> Florian
>> --
>> https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
>>    GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
>>          I love long mails! | https://email.is-not-s.ms/
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt

More information about the PyQt mailing list