Qt: Difference between revisions

From NixOS Wiki
imported>Symphorien
explain how to launch qt apps from a systemd user service
imported>Samueldr
m →‎qt5: fix <code>
Line 13: Line 13:


==== qt5 ====
==== qt5 ====
Qt5 seems (?) to look for plugins in the <code>PATH</code>. This will fail from a systemd user unit for example, because their path is nearly empty by default. As an example, here is a workaround to have </code>usbguard-applet</code> launched from a systemd user unit:
Qt5 seems (?) to look for plugins in the <code>PATH</code>. This will fail from a systemd user unit for example, because their path is nearly empty by default. As an example, here is a workaround to have <code>usbguard-applet</code> launched from a systemd user unit:
{{File|/etc/nixos/configuration.nix|nix|<nowiki>
{{File|/etc/nixos/configuration.nix|nix|<nowiki>
   systemd.user.services.usbguard-applet = {
   systemd.user.services.usbguard-applet = {

Revision as of 20:37, 3 June 2018

Troubleshooting

Cannot mix incompatible Qt library (version 0x_____) with this library (version 0x_____)

This is a known issue, see #30551 for the current status.

This application failed to start because it could not find or load the Qt platform plugin ??? in ""

qt4

Qt4 depends on the environment variable QT_PLUGIN_PATH to find plugins. It is normally already

present in the environment on NixOS at least, but for example systemd user units are launched in a pretty empty environment. A solution is to use the command

systemctl --user import-environment QT_PLUGIN_PATH

from a sane environment. For example add it to the services.xserver.displayManager.sessionCommands option.

qt5

Qt5 seems (?) to look for plugins in the PATH. This will fail from a systemd user unit for example, because their path is nearly empty by default. As an example, here is a workaround to have usbguard-applet launched from a systemd user unit:

/etc/nixos/configuration.nix
  systemd.user.services.usbguard-applet = {
    description = "USBGuard applet";
    partOf = [ "graphical-session.target" ];
    wantedBy = [ "graphical-session.target" ];
    path = [ "/run/current-system/sw/" ]; ### Fix empty PATH to find qt plugins
    serviceConfig = {
      ExecStart = "${pkgs.usbguard}/bin/usbguard-applet-qt";
    };
  };

Debugging methods

As a general rule, exporting QT_DEBUG_PLUGINS=1 make qt print where it looks for plugins.

If a plugin exists in a directory but is ignored with a message like QLibraryPrivate::loadPlugin failed on "/nix/store/...-teamspeak-client-3.1.6/lib/teamspeak/platforms/libqxcb.so" : "Cannot load library /nix/store/...-client-3.1.6/lib/teamspeak/platforms/libqxcb.so: " it can be that the library cannot be dlopen()ed because of dependencies/rpath issues and needs patchelfing. Exporting LD_DEBUG=libs may prove helpful in this scenario.