Description
On PySide6, the following code snippet:
# from PyQt6.QtCore import QVariant, QMetaType # from PyQt6.QtWidgets import QApplication # from PyQt6.QtDBus import QDBusInterface, QDBusConnection, QDBus, QDBusMessage, QDBusArgument from PySide6.QtWidgets import QApplication from PySide6.QtDBus import QDBusInterface, QDBusConnection, QDBus, QDBusMessage SERVICE = "org.freedesktop.Notifications" PATH = "/org/freedesktop/Notifications" INTERFACE = SERVICE app = QApplication([]) bus = QDBusConnection.sessionBus() iface = QDBusInterface(SERVICE, PATH, INTERFACE, bus) assert iface.isValid(), iface.lastError() def _as_uint32(x): # variant = QVariant(x) # successful = variant.convert(QMetaType(QMetaType.Type.UInt.value)) # assert successful # return variant return x def _as_qstringlist(x): # return QDBusArgument(x, QMetaType.Type.QStringList.value) return x reply = iface.callWithArgumentList( QDBus.CallMode.Block, "Notify", [ "test", # app name _as_uint32(0), # replaces_id "", # icon filename "title", "body", _as_qstringlist([]), # actions {}, # hints -1, # timeout ] ) assert reply.type() != QDBusMessage.MessageType.ErrorMessage, reply.errorMessage() print(reply.arguments())
prints:
AssertionError: Type of message, “(sisssasa{sv}i)”, does not match expected type “(susssasa{sv}i)”
due to the freedesktop.org notification spec enforcing that replaces_id needs to be specified as UInt32 rather than Int32.
With PyQt6, the commented out code can be used to explicitly pass a Python int as UInt32 to Qt (it otherwise handles QVariant transparently, like PySide does!). PySide6 seems to lack a similar mechanism, thus making it - from what I can see - impossible to use the notification API from it.
As an aside: PyQt6 also seems to need some code so that the list of strings gets passed as that (as) rather than a list of variable objects (av). That seems unneeded with PySide6.
Attachments
Issue Links
- relates to
-
PYSIDE-2066 Unpredictable sorting of integers with QSortFilterProxyModel
- Reported
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-1904 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
441715,5 | WIP: PySide6: Add QDBusArgument constructors for int/double taking a meta type id | dev | pyside/pyside-setup | Status: NEW | -2 | 0 |
441695,3 | PySide6: Add a conversion from QDBusArgument to QVariant | dev | pyside/pyside-setup | Status: ABANDONED | 0 | 0 |