Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94584

Add API to forbid loading platformthemes or to check/choose current platformtheme

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: QPA
    • Labels:
      None
    • Platform/s:
      Linux/Wayland, Linux/X11

      Description

      If some application uses gtk for some reason (e.g. to query additional settings or to use webkit2gtk) and Qt loads gtk of another version (e.g. application links to gtk3, while the user sets QT_QPA_PLATFORMTHEME=gtk2), it will crash. There's also possibility that application may require gdk_set_allowed_backends to keep gtk's and Qt's display protocol in sync (i.e. make both to use x11 or wayland at the same time, what is critical when window embedding is used), so it can't use gdk_set_allowed_backends before running QGuiApplication and after loading it's too late to use it since gtk_init is already called by Qt.

      Qt already provides QGuiApplication::platformName to check current platform, Qt also provides QApplication::style and QApplication::setStyle to force some style (and avoid loading e.g. QGtkStyle), but there's no API to check platform theme name and/or force some platform theme or to disable platform theme integration at all. Maximum application can do is to set QGuiApplication::setDesktopSettingsAware to false (to disable automatic platformtheme guessing code in Qt) and unset QT_QPA_PLATFORMTHEME variable, but that leads to:
      1. Qt's file chooser stops using system icon theme (application can set it manually via QIcon::setThemeName even if platformtheme is not loaded)
      2. Processes started by that application (e.g. via QDesktopServices::openUrl) will inherit its environment and will look incorrectly (while the parent process can look ok at the same time due to custom widgets and etc)

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            vestbo Tor Arne Vestbø
            Reporter:
            ilya-fedin Ilya Fedin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes