Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

XDG Desktop portal in Qt



  • I'm trying to open file in a Qt app via org.freedesktop.portal.FileChooser. So far it works the thing I'm stuck with is the filters.

    The doc say to use the format filters a(sa(us))

    QDBusMessage message = QDBusMessage::createMethodCall(
        QLatin1String("org.freedesktop.portal.Desktop"),
        QLatin1String("/org/freedesktop/portal/desktop"),
        QLatin1String("org.freedesktop.portal.FileChooser"),
        QLatin1String("OpenFile"));
    
    message << QLatin1String("x11:") << QLatin1String("Open PDF File") <<
    QVariantMap {
            {QLatin1String("handle_token"), getRequestToken()},
            {QLatin1String("multiple"), false},
             {QLatin1String("filters"), QVariantMap {
             {QLatin1String ("PDF File"), QVariantList {
                     {}
                }}
            }}
    };
    

    Can some help me how to write a filter for PDF file.


  • Lifetime Qt Champion

    Hi,

    Not a direct answer but why not use QDesktopService::openUrl ?

    Or are you trying to make your app open that file type ?


Log in to reply