c++qtqt5waylandqt5.7

Qt 5.7 How can I check value of variable QT_QPA_PLATFORM at runtime?


I know how to check default platform, but I need to check in my application if it run on X11 or Wayland. I try this:

QString platform = qgetenv("QT_QPA_PLATFORM");

but it returns an empty string.

On Weston when I run my application I set QT_QPA_PLATFORM to Wayland:

./myApp -platform wayland

but my QString platform is still empty, and default platform name doesn't change either.


Solution

  • You're looking for QGuiApplication::platformName().