aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shared/shared.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-09-01 15:53:43 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-09-03 13:04:55 +0200
commit633a85cd39cdd294283439972cffebcff32ac0cb (patch)
tree51da251a52dbaa431c491aa30d50a7d13ed0200d /examples/quick/shared/shared.h
parent483274ee3e259ddef19d0a00c004ec33c1a89276 (diff)
Install the "shared" example module into macOS bundles
If we build an application bundle we cannot rely on the relative path between the application's and the shared module's output directories. This is somewhat ugly, but as we don't have a comprehensive solution for building application bundles, yet, it's the best we can do right now. In order for the shared bundle to be loaded from the PlugIns directory, we need to add the PlugIns directory to the import path on macOS. Pick-to: 6.2 Change-Id: I5b952420b4bb60af74886a140fa2c6a263d2f730 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/quick/shared/shared.h')
-rw-r--r--examples/quick/shared/shared.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/quick/shared/shared.h b/examples/quick/shared/shared.h
index 7f51b3d505..96bef11d98 100644
--- a/examples/quick/shared/shared.h
+++ b/examples/quick/shared/shared.h
@@ -52,6 +52,14 @@
#include <QQmlEngine>
#include <QQmlFileSelector>
#include <QQuickView> //Not using QQmlApplicationEngine because many examples don't have a Window{}
+
+#ifdef Q_OS_MACOS
+#define ADD_MACOS_BUNDLE_IMPORT_PATH \
+ view.engine()->addImportPath(app.applicationDirPath() + QStringLiteral("/../PlugIns"));
+#else
+#define ADD_MACOS_BUNDLE_IMPORT_PATH
+#endif
+
#define DECLARATIVE_EXAMPLE_MAIN(NAME) int main(int argc, char* argv[]) \
{\
QGuiApplication app(argc,argv);\
@@ -59,6 +67,7 @@
app.setOrganizationDomain("qt-project.org");\
app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
QQuickView view;\
+ ADD_MACOS_BUNDLE_IMPORT_PATH\
view.engine()->addImportPath(QStringLiteral(":/"));\
if (qEnvironmentVariableIntValue("QT_QUICK_CORE_PROFILE")) {\
QSurfaceFormat f = view.format();\