Pass QIcon over D-Bus

Florian Bruhin me at
Wed Jun 15 15:36:25 BST 2022


On Wed, Jun 15, 2022 at 04:12:13PM +0200, JakobDev wrote:
> There is a working C++ implementation but I couldn't get it to work in
> Python.

Qt DBus is still a lot of black magic to me, but I noticed that you do:

    QIcon.fromTheme("utilities-terminal").pixmap(512, 512).save(buffer, "PNG")
    message.setArguments(["", "Name", QDBusVariant(buffer), {}])

while the C++ code does:

    QIcon::fromTheme("utilities-terminal").pixmap(maxSize, maxSize).save(&buffer,"PNG");
    PortalIcon icon {QStringLiteral("bytes"), QDBusVariant(buffer.buffer())};

    message << parentWindowId() << QStringLiteral("Patschen")
            << QVariant::fromValue(QDBusVariant(QVariant::fromValue(icon)))
            << ...

You seem to be missing the second step there: creating a PortalIcon
object with the "bytes" string in it, and the actual data from the
QBuffer (as a QByteArray).

I don't know how far it'll get you, but I do something vaguely similar

The data is then added here:


            me at | |
       GPG: 916E B0C8 FD55 A072 |
             I love long mails! |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <>

More information about the PyQt mailing list