Deprecated QScoketNotifier::activated signal overload

Florian Bruhin me at the-compiler.org
Fri Mar 17 17:36:01 GMT 2023


Hey,

When connecting to a QSocketNotifier's activated signal, it looks like
PyQt insists on using the deprecated variant:

QSocketNotifier::activated(int socket)
https://doc.qt.io/qt-6/qsocketnotifier-obsolete.html#activated-1

Rather than using the new replacement (since Qt 5.15):

QSocketNotifier::activated(QSocketDescriptor socket, QSocketNotifier::Type type)
https://doc.qt.io/qt-6/qsocketnotifier.html#activated

Example:

---------------------------------------------------------------------

import os, sys
from PyQt6.QtCore import QSocketNotifier, QCoreApplication, pyqtSlot

# @pyqtSlot("QSocketDescriptor", "QSocketNotifier::Type")
def on_notifier_activated(socket, typ):
    print(type(socket), socket)
    print(type(typ), typ)

app = QCoreApplication(sys.argv)
reader, writer = os.pipe()
notifier = QSocketNotifier(reader, QSocketNotifier.Type.Read)
notifier.activated.connect(on_notifier_activated)
os.write(writer, b"x")
app.exec()

---------------------------------------------------------------------

Without the @pyqtSlot, this leads to:

qt.core.qobject.connect: QObject::connect: Connecting from COMPAT signal (QSocketNotifier::activated(int))
TypeError: on_notifier_activated() missing 1 required positional argument: 'typ'

(first line with Qt debug build only).

With the @pyqtSlot, instead:

Traceback (most recent call last):
  File "/home/florian/tmp/test.py", line 4, in <module>
    @pyqtSlot("QSocketDescriptor", "QSocketNotifier::Type")
TypeError: C++ type 'QSocketDescriptor' is not supported as a pyqtSlot argument type

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230317/53158624/attachment.sig>


More information about the PyQt mailing list