QDBusContext / sending error replies via DBus
Phil Thompson
phil at riverbankcomputing.com
Mon Jun 20 17:30:56 BST 2022
On 20/06/2022 17:15, Florian Bruhin wrote:
> Hey,
>
> I currently have this working example of a DBus service implemented via
> PyQt:
> https://github.com/qutebrowser/qutebrowser/blob/master/tests/end2end/fixtures/notificationserver.py#L45
>
> Now I'd like to return an error reply to the DBus client in certain
> circumstances. How can I do that? With normal Qt code, one would
> apparently inherit from QDBusContext instead of QObject, and use
> sendErrorReply(): https://doc.qt.io/qt-6/qdbuscontext.html
>
> When a slot is called in an object due to a signal delivery or due
> to a remote method call, it is sometimes necessary to know the
> context in which that happened. In particular, if the slot
> determines that it wants to send the reply at a later opportunity
> or
> if it wants to reply with an error, the context is needed.
>
> However, that class seems to be missing in both PyQt5 and PyQt6.
The docs suggest inheriting from QDBusContext *and* QObject. That
suggests creating a QPyDBusQObjectWithContext class in C++ and wrapping
that. There must be a reason why Qt doesn't contain such a class.
Phil
More information about the PyQt
mailing list