Skip to content

Commit 0c09af2

Browse files
committed
Minor fix for some environments that don't have QT_QPA_PLATFORM defined
1 parent d068a96 commit 0c09af2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
4040

4141
int main(int argc, char *argv[])
4242
{
43+
// Set Qt platform to XCB (X11) if not already set and we're in X11 environment
44+
if (qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM")) {
45+
if (!qEnvironmentVariableIsEmpty("DISPLAY") && qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")) {
46+
qputenv("QT_QPA_PLATFORM", "xcb");
47+
}
48+
}
49+
4350
QApplication a(argc, argv);
4451

4552
if (a.arguments().contains("--version") || a.arguments().contains("-v") ) {

0 commit comments

Comments
 (0)