This is basically a cherry pick of 77ec43d5 (Don't force QT_QPA_PLATFORM=wayland), except for X11.
mentioned in commit 8633f995