diff --git a/modules/gui/src/python_shell/python_interpreter_worker.hh b/modules/gui/src/python_shell/python_interpreter_worker.hh
index 7d38dd544b040c86a19106751bf4813fe165dd1f..4c36b27507f44879fbe9346e49cc7ee3b0265e31 100644
--- a/modules/gui/src/python_shell/python_interpreter_worker.hh
+++ b/modules/gui/src/python_shell/python_interpreter_worker.hh
@@ -3,8 +3,11 @@
 
 #include <csignal>
 #include <utility>
-#include <boost/python.hpp>
-#include <boost/shared_ptr.hpp>
+// workaround for QTBUG-22829: https://bugreports.qt-project.org/browse/QTBUG-22829
+#ifndef Q_MOC_RUN
+  #include <boost/python.hpp>
+  #include <boost/shared_ptr.hpp>
+#endif
 #include "output_redirector.hh"
 #include <QObject>
 #include <QQueue>