Icon from theme not working in QML in eglfs mode

327 Views Asked by At

This works on X, but not on eglfs.

Button {
    icon.name: "computer-fail-symbolic"
    icon.height: 96
    icon.width: 96
    display: AbstractButton.TextUnderIcon
    text: "BSOD"
    flat: true
}

...

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));

    QIcon::setThemeName( "Papirus" );

    QtWebEngine::initialize();
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:/");
    const QUrl url(QStringLiteral("qrc:/main.qml"));

    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);
    return app.exec();
}

Also not working buttons paddings.

How to fix icons?

1

There are 1 best solutions below

0
On

From the docs:

Note: By default, only X11 will support themed icons. In order to use themed icons on Mac and Windows, you will have to bundle a compliant theme in one of your themeSearchPaths() and set the appropriate themeName().

It doesn't mention non-X11 based Linux platforms. It might still work if you set the appropriate themeSearchPath. But in general, this seems like a desktop app feature, not one for an embedded platform using eglfs, so it might not work at all for you.