File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616#include < QSlider>
1717#include < Standard_WarningsRestore.hxx>
1818
19+ #include < OSD_Environment.hxx>
1920#include < Standard_Version.hxx>
2021
2122// ! Main application window.
@@ -166,6 +167,23 @@ class MyMainWindow : public QMainWindow
166167
167168int main (int theNbArgs, char ** theArgVec)
168169{
170+ #if defined(_WIN32)
171+ //
172+ #elif defined(__APPLE__)
173+ //
174+ #else
175+ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
176+ // Qt6 tries to use Wayland platform by default, which is incompatible with OCCT depending on Xlib;
177+ // Force 'xcb' platform plugin (alternatively, could be passed QApplication as '-platfom xcb' argument).
178+ OSD_Environment aQpaPlat (" QT_QPA_PLATFORM" );
179+ if (aQpaPlat.Value ().IsEmpty ())
180+ {
181+ aQpaPlat.SetValue (" xcb" );
182+ aQpaPlat.Build ();
183+ }
184+ #endif
185+ #endif
186+
169187 QApplication aQApp (theNbArgs, theArgVec);
170188
171189 QCoreApplication::setApplicationName (" OCCT Qt/QOpenGLWidget Viewer sample" );
Original file line number Diff line number Diff line change 1616#include < QSlider>
1717#include < Standard_WarningsRestore.hxx>
1818
19+ #include < OSD_Environment.hxx>
1920#include < Standard_Version.hxx>
2021
2122// ! Main application window.
@@ -168,6 +169,23 @@ class MyMainWindow : public QMainWindow
168169
169170int main (int theNbArgs, char ** theArgVec)
170171{
172+ #if defined(_WIN32)
173+ //
174+ #elif defined(__APPLE__)
175+ //
176+ #else
177+ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
178+ // Qt6 tries to use Wayland platform by default, which is incompatible with OCCT depending on Xlib;
179+ // Force 'xcb' platform plugin (alternatively, could be passed QApplication as '-platfom xcb' argument).
180+ OSD_Environment aQpaPlat (" QT_QPA_PLATFORM" );
181+ if (aQpaPlat.Value ().IsEmpty ())
182+ {
183+ aQpaPlat.SetValue (" xcb" );
184+ aQpaPlat.Build ();
185+ }
186+ #endif
187+ #endif
188+
171189 QApplication aQApp (theNbArgs, theArgVec);
172190
173191 QCoreApplication::setApplicationName (" OCCT Qt/QWidget Viewer sample" );
You can’t perform that action at this time.
0 commit comments