如何将 (Py)Gtk Gio.ThemedIcon 转换为 (Py)Qt5 中可用的任何内容(QImage、QIcon 等)?

How can I convert a (Py)Gtk Gio.ThemedIcon to anything usable in (Py)Qt5 (QImage, QIcon, etc)?

我有这段代码可以获取我的 linux 系统中能够打开 png 文件的所有程序的列表:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio

app_list = Gio.app_info_get_all_for_type('image/png')

然后我可以通过以下方式获取程序的图标:

app = app_list[0]
g_icon = app.get_icon()

这个returns<Gio.ThemedIcon object at 0x7f2681640d80 (GThemedIcon at 0x25500a0)>.
我怎样才能将这个 Gio.ThemedIcon 对象转换为我可以用来创建 QIcon 或 QImage 的任何东西(pixbuf、字节等)?

在Qt中ThemedIcon has the get_names() function that returns a list of possible theme names. You can use the static fromTheme()获取图标:

app = app_list[0]
g_icon = app.get_icon()
for name in g_icon.get_names():
    icon = QtGui.QIcon.fromTheme(name)
    if not icon.isNull():
        break